Commit 50a4d8bb authored by Florian's avatar Florian

added Upper and Lower Timestamp Bound Filter

parent 7baf111f
......@@ -18,7 +18,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.editors;bundle-version="3.9.0",
org.eclipse.jdt.core;bundle-version="3.11.0",
org.eclipse.equinox.registry,
org.eclipse.swt
org.eclipse.swt,
org.eclipse.nebula.widgets.cdatetime;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .,
......
package kieker.tools.eclipse.analysis.filter;
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;
import kieker.analysis.domain.OperationCall;
/**
* Filter for Minimum and Maximum
......@@ -24,56 +17,57 @@ public class ThresholdFilter extends ViewerFilter {
};
private Limit limitType;
private int colIndex;
private String searchString;
private Long timestamp;
public ThresholdFilter() {
this(Limit.UPPER, 0);
this(Limit.UPPER);
}
/**
* Constructor for a TreeFilter for the column defined by the parameter
* Constructor for a ThresholdFilter for the column defined by the parameter
* with a lower or upper limit defined by l
*
* @param i
* @param l
* lower or upper limit
* @param colIndex
* column index
*
*/
public ThresholdFilter(Limit l, int colIndex) {
public ThresholdFilter(Limit l) {
limitType = l;
this.colIndex = colIndex;
}
/**
* Sets the filter string
* Sets the filter timestamp
*
* @param s
* string to filter
* @param timestamp
* timestamp to filter
*/
public void setSearchText(String s) {
// literalize string to disable regular expressions, inputs like "test("
// for a method filter would otherwise lead to exceptions
s = Pattern.quote(s);
// add wildcards at the start and the end to also filter for objects
// which contains the search string
this.searchString = ".*" + s + ".*";
public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
// empty search, all objects are true
if (searchString == null || searchString.length() == 0) {
if (timestamp == null || timestamp.longValue() == 0) {
return true;
}
TreeViewer treeViewer = (TreeViewer) viewer;
// checks if the index is in bounds of the column count
if (0 <= colIndex && colIndex < treeViewer.getTree().getColumns().length) {
ColumnLabelProvider labelProvider = (ColumnLabelProvider) treeViewer.getLabelProvider(colIndex);
String labelText = labelProvider.getText(element);
return labelText.matches(searchString);
}
OperationCall opCall = (OperationCall) element;
long opCallTimestamp = opCall.getTimestamp();
return false;
if (Limit.UPPER.equals(limitType)) {
if (opCallTimestamp <= timestamp) {
return true;
} else
return false;
} else {
if (opCallTimestamp >= timestamp) {
return true;
} else
return false;
}
}
......
......@@ -5,17 +5,20 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.nebula.widgets.cdatetime.CDateTime;
import kieker.tools.eclipse.analysis.filter.ThresholdFilter;
import kieker.tools.eclipse.analysis.filter.TreeFilter;
import kieker.tools.eclipse.analysis.listener.DateTimeFilterSelectionListener;
import kieker.tools.eclipse.analysis.listener.FilterModifyListener;
public class FilterHelper {
public static Text createFilterText(Composite composite, String message) {
Text searchText = new Text(composite, SWT.BORDER | SWT.SEARCH);
Text searchText = new Text(composite, SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL);
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.horizontalSpan = 1;
gridData.horizontalSpan = 4;
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
searchText.setLayoutData(gridData);
......@@ -23,6 +26,26 @@ public class FilterHelper {
return searchText;
}
public static CDateTime createFilterCDateTime(Composite composite, String message, int style){
CDateTime dateTime = new CDateTime(composite, style );
dateTime.setNullText(message);
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.horizontalSpan = 3;
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
dateTime.setLayoutData(gridData);
return dateTime;
}
public static ThresholdFilter createFilter(TreeViewer viewer, ThresholdFilter.Limit limit, CDateTime date, CDateTime time) {
ThresholdFilter filter = new ThresholdFilter(limit);
DateTimeFilterSelectionListener listener = new DateTimeFilterSelectionListener(viewer, filter, date, time, limit);
date.addSelectionListener(listener);
time.addSelectionListener(listener);
return filter;
}
public static TreeFilter createFilter(TreeViewer viewer, int col, Text text) {
TreeFilter filter = new TreeFilter(col);
......
......@@ -54,11 +54,11 @@ public class TabHelper {
public static void createTreeTab(TabFolder tabFolder, int tabIndex, String tabLabel, ColumnDef[] colDef,
int operationCol, int componentCol, int containerCol, IContentProvider provider,
AnalysisViewerComparator comparator, IWorkbenchPartSite site, List<ColumnViewer> viewerList,
List<TabItem> tabList, List<List<Text>> filterTextLists) {
List<TabItem> tabList, List<List<Text>> filterTextLists, boolean hasDateTimeFilter) {
TabItem tab = new TabItem(tabFolder, SWT.NULL);
tab.setText(tabLabel);
TreeViewer viewer = TreeHelper.createTree(site, tabFolder, tab, operationCol, componentCol, containerCol,
filterTextLists);
TreeViewer viewer = TreeHelper.createTree(site, tabFolder, tab, hasDateTimeFilter, operationCol, componentCol,
containerCol, filterTextLists);
TreeHelper.createTreeViewerColumns(viewer, comparator, colDef);
......@@ -68,4 +68,5 @@ public class TabHelper {
tabList.add(tabIndex, tab);
viewerList.add(tabIndex, viewer);
}
}
......@@ -8,6 +8,8 @@ import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.nebula.widgets.cdatetime.CDT;
import org.eclipse.nebula.widgets.cdatetime.CDateTime;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
......@@ -27,15 +29,20 @@ import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPartSite;
import kieker.tools.eclipse.analysis.comparator.AnalysisViewerComparator;
import kieker.tools.eclipse.analysis.filter.ThresholdFilter;
import kieker.tools.eclipse.analysis.filter.TreeFilter;
import kieker.tools.eclipse.analysis.model.ColumnDef;
import kieker.tools.eclipse.analysis.resources.view.Messages;
public class TreeHelper {
public static TreeViewer createTree(IWorkbenchPartSite site, Composite parent, TabItem tab, int operationCol, int componentCol, int containerCol, List<List<Text>> filterTextLists ) {
public static TreeViewer createTree(IWorkbenchPartSite site, Composite parent, TabItem tab,
boolean hasDateTimeFilter, int operationCol, int componentCol, int containerCol,
List<List<Text>> filterTextLists) {
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(3, false);
GridLayout layout = new GridLayout(12, false);
layout.makeColumnsEqualWidth = true;
composite.setLayout(layout);
Text methodSearchText = FilterHelper.createFilterText(composite, Messages.AnalysisTreeView_FilterOperations);
......@@ -46,16 +53,31 @@ public class TreeHelper {
filterTexts.add(methodSearchText);
filterTexts.add(componentSearchText);
filterTexts.add(containerSearchText);
filterTextLists.add(filterTexts);
CDateTime lowerDateFilter = null;
CDateTime lowerTimeFilter = null;
CDateTime upperDateFilter = null;
CDateTime upperTimeFilter = null;
if (hasDateTimeFilter) {
lowerDateFilter = FilterHelper.createFilterCDateTime(composite, Messages.AnalysisTreeView_FilterLowerDate,
CDT.BORDER | CDT.DROP_DOWN | CDT.DATE_MEDIUM | CDT.CLOCK_DISCRETE);
lowerTimeFilter = FilterHelper.createFilterCDateTime(composite, Messages.AnalysisTreeView_FilterLowerTime,
CDT.BORDER | CDT.DROP_DOWN | CDT.TIME_SHORT | CDT.CLOCK_DISCRETE);
upperDateFilter = FilterHelper.createFilterCDateTime(composite, Messages.AnalysisTreeView_FilterUpperDate,
CDT.BORDER | CDT.DROP_DOWN | CDT.DATE_MEDIUM | CDT.CLOCK_DISCRETE);
upperTimeFilter = FilterHelper.createFilterCDateTime(composite, Messages.AnalysisTreeView_FilterUpperTime,
CDT.BORDER | CDT.DROP_DOWN | CDT.TIME_SHORT | CDT.CLOCK_DISCRETE);
}
TreeViewer viewer = new TreeViewer(composite, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
tab.setControl(composite);
// Layout the viewer
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.horizontalSpan = 3;
gridData.horizontalSpan = 12;
gridData.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
......@@ -90,13 +112,17 @@ public class TreeHelper {
filterList.add(FilterHelper.createFilter(viewer, componentCol, componentSearchText));
filterList.add(FilterHelper.createFilter(viewer, containerCol, containerSearchText));
if (hasDateTimeFilter) {
viewer.addFilter(FilterHelper.createFilter(viewer, ThresholdFilter.Limit.LOWER, lowerDateFilter, lowerTimeFilter));
viewer.addFilter(FilterHelper.createFilter(viewer, ThresholdFilter.Limit.UPPER, upperDateFilter, upperTimeFilter));
}
for (TreeFilter f : filterList) {
viewer.addFilter(f);
}
return viewer;
}
static void addTreeViewerContextMenu(IWorkbenchPartSite site, TreeViewer viewer) {
MenuManager manager = new MenuManager();
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
......@@ -107,7 +133,8 @@ public class TreeHelper {
site.setSelectionProvider(viewer);
}
public static void createTreeViewerColumns(TreeViewer viewer, AnalysisViewerComparator comparator, ColumnDef[] cols) {
public static void createTreeViewerColumns(TreeViewer viewer, AnalysisViewerComparator comparator,
ColumnDef[] cols) {
int i = 0;
for (ColumnDef col : cols) {
createTreeViewerColumn(viewer, comparator, col.getStyle(), col.getName(), col.getWidth(),
......@@ -115,8 +142,8 @@ public class TreeHelper {
}
}
public static void createTreeViewerColumn(TreeViewer viewer, AnalysisViewerComparator comparator, int style, String title, int width,
ColumnLabelProvider provider, int index) {
public static void createTreeViewerColumn(TreeViewer viewer, AnalysisViewerComparator comparator, int style,
String title, int width, ColumnLabelProvider provider, int index) {
TreeViewerColumn viewCol = new TreeViewerColumn(viewer, style);
TreeColumn col = viewCol.getColumn();
col.setText(title);
......@@ -125,7 +152,7 @@ public class TreeHelper {
col.addSelectionListener(getSelectionAdapter(viewer, comparator, col, index));
viewCol.setLabelProvider(provider);
}
static SelectionAdapter getSelectionAdapter(final TreeViewer viewer, final AnalysisViewerComparator comparator,
final TreeColumn column, final int index) {
SelectionAdapter selectionAdapter = new SelectionAdapter() {
......@@ -140,5 +167,5 @@ public class TreeHelper {
};
return selectionAdapter;
}
}
package kieker.tools.eclipse.analysis.listener;
import java.util.Calendar;
import java.util.Date;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.nebula.widgets.cdatetime.CDateTime;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import kieker.tools.eclipse.analysis.filter.ThresholdFilter;
import kieker.tools.eclipse.analysis.filter.ThresholdFilter.Limit;
public class DateTimeFilterSelectionListener implements SelectionListener {
TreeViewer viewer;
ThresholdFilter filter;
CDateTime date;
CDateTime time;
Limit limit;
public DateTimeFilterSelectionListener(TreeViewer viewer, ThresholdFilter filter, CDateTime date, CDateTime time,
Limit limit) {
this.viewer = viewer;
this.filter = filter;
this.date = date;
this.time = time;
this.limit = limit;
}
@Override
public void widgetSelected(SelectionEvent e) {
Calendar calendar = Calendar.getInstance();
Date d = date.getSelection();
Date t = time.getSelection();
int year = 0;
int month = 0;
int day = 0;
int hours = 0;
int minutes = 0;
int seconds = 0;
if (d != null) {
calendar.setTime(d);
year = calendar.get(Calendar.YEAR);
month = calendar.get(Calendar.MONTH);
day = calendar.get(Calendar.DAY_OF_MONTH);
} else {
filter.setTimestamp(null);
viewer.refresh();
return;
}
if (t != null) {
calendar.setTime(t);
hours = calendar.get(Calendar.HOUR_OF_DAY);
minutes = calendar.get(Calendar.MINUTE);
} else {
if (Limit.UPPER.equals(limit)) {
hours = 23;
minutes = 59;
} else {
hours = minutes = 0;
}
}
if (Limit.UPPER.equals(limit)) {
seconds = 59;
} else {
seconds = 0;
}
Date newDate = new Date();
calendar.set(year, month, day, hours, minutes);
calendar.set(Calendar.SECOND, seconds);
newDate = calendar.getTime();
long timestamp = newDate.getTime();
timestamp *= 1000000;
if (Limit.UPPER.equals(limit)) {
timestamp += 999999;
}
filter.setTimestamp(timestamp);
viewer.refresh();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
}
......@@ -29,6 +29,10 @@ public class Messages extends NLS {
public static String AnalysisTreeView_FilterOperations;
public static String AnalysisTreeView_FilterComponents;
public static String AnalysisTreeView_FilterContainer;
public static String AnalysisTreeView_FilterLowerDate;
public static String AnalysisTreeView_FilterLowerTime;
public static String AnalysisTreeView_FilterUpperDate;
public static String AnalysisTreeView_FilterUpperTime;
public static String PluginPreferencesPage_GroupAppearance;
public static String PluginPreferencesPage_GroupFilter;
......
......@@ -36,9 +36,13 @@ PluginPreferencesPage_ComponentsLong=Long representation: kieker.examples.bookst
PluginPreferencesPage_Components=Components
PluginPreferencesPage_AnalysisAdditional=Activate additional checks during trace reconstruction
PluginPreferencesPage_Timestamps=Timestamps
AnalysisTreeView_FilterOperations=Filter Operations
AnalysisTreeView_FilterComponents=Filter Components
AnalysisTreeView_FilterContainer=Filter Container
AnalysisTreeView_FilterOperations=<Filter Operations>
AnalysisTreeView_FilterComponents=<Filter Components>
AnalysisTreeView_FilterContainer=<Filter Container>
AnalysisTreeView_FilterLowerDate=<Filter by date (lower limit)>
AnalysisTreeView_FilterLowerTime=<Filter by time (lower limit)>
AnalysisTreeView_FilterUpperDate=<Filter by date (upper limit)>
AnalysisTreeView_FilterUpperTime=<Filter by time (upper limit)>
PluginPreferencesPage_GroupFilter=Filter
PluginPreferencesPage_FilterCaseSensitive=Case Sensitive
PluginPreferencesPage_PercentReference=Refer to topmost method call for percentage calculation
\ No newline at end of file
......@@ -36,9 +36,13 @@ PluginPreferencesPage_ComponentsShort=Kurze Darstellung: Catalog
PluginPreferencesPage_ComponentsLong=Lange Darstellung: kieker.examples.bookstore.Catalog
PluginPreferencesPage_AnalysisAdditional=Aktiviere weitere berprfungen whrend der Trace Rekonstruktion
PluginPreferencesPage_Timestamps=Zeitstempel
AnalysisTreeView_FilterOperations=Filter Methoden
AnalysisTreeView_FilterComponents=Filter Komponenten
AnalysisTreeView_FilterContainer=Filter Container
AnalysisTreeView_FilterOperations=<Filter Methoden>
AnalysisTreeView_FilterComponents=<Filter Komponenten>
AnalysisTreeView_FilterContainer=<Filter Container>
AnalysisTreeView_FilterLowerDate=<Filtere nach Datum (untere Grenze)>
AnalysisTreeView_FilterLowerTime=<Filtere nach Datum (untere Grenze)>
AnalysisTreeView_FilterUpperDate=<Filtere nach Datum (obere Grenze)>
AnalysisTreeView_FilterUpperTime=<Filtere nach Zeit (obere Grenze)>
PluginPreferencesPage_GroupFilter=Filter
PluginPreferencesPage_FilterCaseSensitive=Gro-/Kleinschreibung beachten
PluginPreferencesPage_PercentReference=Prozentuale Berechnung auf den obersten Methodenaufruf beziehen
\ No newline at end of file
......@@ -205,7 +205,7 @@ public class AnalysisView extends ViewPart {
final int containerCol = 3;
TabHelper.createTreeTab(tabFolder, TRACETAB, title, colDef, operationCol, componentCol, containerCol, provider,
comparator, getSite(), viewerList, tabList, filterTextLists);
comparator, getSite(), viewerList, tabList, filterTextLists, true);
}
/**
......@@ -242,7 +242,7 @@ public class AnalysisView extends ViewPart {
final int containerCol = 2;
TabHelper.createTreeTab(tabFolder, AGGRTRACETAB, title, colDef, operationCol, componentCol, containerCol,
provider, comparator, getSite(), viewerList, tabList, filterTextLists);
provider, comparator, getSite(), viewerList, tabList, filterTextLists, false);
}
/**
......@@ -274,7 +274,7 @@ public class AnalysisView extends ViewPart {
final int containerCol = 2;
TabHelper.createTreeTab(tabFolder, OPCALLTAB, title, colDef, operationCol, componentCol, containerCol, provider,
comparator, getSite(), viewerList, tabList, filterTextLists);
comparator, getSite(), viewerList, tabList, filterTextLists, true);
}
/**
......@@ -310,7 +310,7 @@ public class AnalysisView extends ViewPart {
final int containerCol = 2;
TabHelper.createTreeTab(tabFolder, AGGROPCALLTAB, title, colDef, operationCol, componentCol, containerCol,
provider, comparator, getSite(), viewerList, tabList, filterTextLists);
provider, comparator, getSite(), viewerList, tabList, filterTextLists, false);
}
/**
......
......@@ -24,4 +24,11 @@
version="0.0.0"
unpack="false"/>
<plugin
id="kieker.tools.eclipse.analysis"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>
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