Commit dc8c1da6 authored by Florian's avatar Florian

replaced FilteredTree with Tree with custom Filter and added jump action from...

replaced FilteredTree with Tree with custom Filter and added jump action from aggregated op calls to op calls
parent b35532c2
package kieker.tools.eclipse.analysis.handler;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.viewers.ColumnViewer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.handlers.HandlerUtil;
import kieker.analysis.domain.AggregatedOperationCall;
import kieker.analysis.domain.OperationCall;
import kieker.tools.eclipse.analysis.provider.DataProvider;
import kieker.tools.eclipse.analysis.provider.label.ComponentLabelProvider;
import kieker.tools.eclipse.analysis.provider.label.ContainerLabelProvider;
import kieker.tools.eclipse.analysis.provider.label.OperationLabelProvider;
import kieker.tools.eclipse.analysis.view.AnalysisTreeView;
public class SelectOpCallsFromAggregatedOpCallHandler extends AbstractHandler {
......@@ -26,49 +24,38 @@ public class SelectOpCallsFromAggregatedOpCallHandler extends AbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
try {
IViewPart partView = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
.showView(AnalysisTreeView.VIEWNAME);
.showView(AnalysisTreeView.VIEWNAME);
ISelection sel = HandlerUtil.getCurrentSelection(event);
if (sel instanceof IStructuredSelection) {
Object selected= ((IStructuredSelection) sel).getFirstElement();
Object selected = ((IStructuredSelection) sel).getFirstElement();
if (selected instanceof AggregatedOperationCall) {
AggregatedOperationCall aggrOpCall = (AggregatedOperationCall) selected;
String container = aggrOpCall.getContainer();
String component = aggrOpCall.getComponent();
String operation = aggrOpCall.getOperation();
List<TreePath> path = new ArrayList<TreePath>();
List<OperationCall> opCalls = DataProvider.getOperationCalls();
for(OperationCall opCall : opCalls){
if(container.equals(opCall.getContainer()) && component.equals(opCall.getComponent()) && operation.equals(opCall.getOperation())){
path.add(new TreePath(new Object[]{opCall}));
}
}
TreePath[] pathArray = new TreePath[path.size()];
for(int i = 0; i<path.size(); i++){
pathArray[i] = path.get(i);
}
ContainerLabelProvider containerLabelProvider = new ContainerLabelProvider();
String container = containerLabelProvider.getString(aggrOpCall);
ComponentLabelProvider componentLabelProvider = new ComponentLabelProvider();
String component = componentLabelProvider.getString(aggrOpCall);
OperationLabelProvider operationLabelProvider = new OperationLabelProvider();
String operation = operationLabelProvider.getString(aggrOpCall);
if (partView instanceof AnalysisTreeView) {
AnalysisTreeView view = (AnalysisTreeView) partView;
List<ColumnViewer> viewer = view.getViewerList();
ColumnViewer colView = viewer.get(AnalysisTreeView.OPCALLTAB);
colView.setSelection(new TreeSelection(pathArray), true);
List<Text> filterTexts = view.getFilterTextLists().get(AnalysisTreeView.OPCALLTAB);
filterTexts.get(0).setText(operation);
filterTexts.get(1).setText(component);
filterTexts.get(2).setText(container);
view.getViewerList().get(AnalysisTreeView.OPCALLTAB).refresh();
view.setFocus(AnalysisTreeView.OPCALLTAB);
}
}
}
}
} catch (PartInitException e) {
e.printStackTrace();
}
return null;
}
}
package kieker.tools.eclipse.analysis.helper;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
/**
* @author Florian Echternkamp
*/
public class ComponentFilter extends ViewerFilter {
private String searchString;
private int index;
public ComponentFilter() {
index = 0;
}
public ComponentFilter(int i) {
index = i;
}
public void setSearchText(String s) {
// ensure that the value can be used for matching
this.searchString = ".*" + s + ".*";
}
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (searchString == null || searchString.length() == 0) {
return true;
}
TreeViewer treeViewer = (TreeViewer) viewer;
ColumnLabelProvider labelProvider = (ColumnLabelProvider) treeViewer.getLabelProvider(index);
String labelText = labelProvider.getText(element);
return labelText.matches(searchString);
}
}
......@@ -3,22 +3,53 @@ package kieker.tools.eclipse.analysis.helper;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.dialogs.PatternFilter;
import org.eclipse.jface.viewers.ViewerFilter;
/**
* @author Florian Echternkamp
*/
public class TreeFilter extends PatternFilter {
protected boolean isLeafMatch(final Viewer viewer, final Object element) {
TreeViewer treeViewer = (TreeViewer)viewer;
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 |= wordMatches(labelText);
}
return isMatch;
}
public class TreeFilter extends ViewerFilter {
private String searchString;
private int index;
public TreeFilter() {
index = -1;
}
public TreeFilter(int i) {
index = i;
}
public void setSearchText(String s) {
// ensure that the value can be used for matching
this.searchString = ".*" + s + ".*";
}
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (searchString == null || searchString.length() == 0) {
return true;
}
TreeViewer treeViewer = (TreeViewer) viewer;
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;
}
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;
}
}
......@@ -63,21 +63,21 @@ public class DataProvider {
public static List<OperationCall> getOperationCalls() {
if(traceImportConfiguration == null){
return null;
return new ArrayList<>();
}
return traceImportConfiguration.getOperationCalls();
}
public static List<AggregatedOperationCall> getAggreagtedOperationCalls() {
if(traceImportConfiguration == null){
return null;
return new ArrayList<>();
}
return traceImportConfiguration.getAggregatedOperationCalls();
}
public static List<OperationCall> getTraces() {
if(traceImportConfiguration == null){
return null;
return new ArrayList<>();
}
List<Trace> traces = traceImportConfiguration.getTraces();
List<OperationCall> opCall = new ArrayList<>();
......@@ -89,7 +89,7 @@ public class DataProvider {
public static List<AggregatedOperationCall> getAggregatedTraces(){
if(traceImportConfiguration == null){
return null;
return new ArrayList<>();
}
List<AggregatedTrace> traces = traceImportConfiguration.getAggregatedTraces();
List<AggregatedOperationCall> aggOpCall = new ArrayList<>();
......@@ -101,7 +101,7 @@ public class DataProvider {
public static List<KiekerMetadataRecord> getMetadata(){
if(traceImportConfiguration == null){
return null;
return new ArrayList<>();
}
return traceImportConfiguration.getMetadataRecords();
}
......
......@@ -21,9 +21,12 @@ 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.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
......@@ -31,11 +34,11 @@ import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.dialogs.FilteredTree;
import org.eclipse.ui.part.ViewPart;
import kieker.tools.eclipse.analysis.helper.CallViewerComparator;
......@@ -45,11 +48,11 @@ import kieker.tools.eclipse.analysis.model.ColumnDef;
public abstract class AbstractJFaceView extends ViewPart {
protected ImageRegistry ir;
private List<TreeFilter> treeFilterList = new ArrayList<>();
public List<TreeFilter> getTreeFilterList() {
return treeFilterList;
List<List<Text>> filterTextLists = new ArrayList<List<Text>>();
public List<List<Text>> getFilterTextLists() {
return filterTextLists;
}
@Override
......@@ -72,17 +75,63 @@ public abstract class AbstractJFaceView extends ViewPart {
return viewerColumn;
}
TreeViewer createTree(Composite parent, TabItem tab) {
Text createFilterText(Composite composite, String message) {
Text searchText = new Text(composite, SWT.BORDER | SWT.SEARCH);
GridData gridData = new GridData();
gridData.verticalAlignment = GridData.FILL;
gridData.horizontalSpan = 1;
gridData.grabExcessHorizontalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
searchText.setLayoutData(gridData);
searchText.setMessage(message);
return searchText;
}
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();
}
});
return filter;
}
TreeViewer createTree(Composite parent, TabItem tab, int operationCol, int componentCol, int containerCol) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new FillLayout());
GridLayout layout = new GridLayout(3, false);
composite.setLayout(layout);
TreeFilter filter = new TreeFilter();
treeFilterList.add(filter);
FilteredTree filteredTree = new FilteredTree(composite, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL,
filter, true);
TreeViewer viewer = filteredTree.getViewer();
Text methodSearchText = createFilterText(composite, Messages.AnalysisTreeView_FilterOperations);
Text componentSearchText = createFilterText(composite, Messages.AnalysisTreeView_FilterComponents);
Text containerSearchText = createFilterText(composite, Messages.AnalysisTreeView_FilterContainer);
List<Text> filterTexts = new ArrayList<Text>();
filterTexts.add(methodSearchText);
filterTexts.add(componentSearchText);
filterTexts.add(containerSearchText);
filterTextLists.add(filterTexts);
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.grabExcessHorizontalSpace = true;
gridData.grabExcessVerticalSpace = true;
gridData.horizontalAlignment = GridData.FILL;
viewer.getControl().setLayoutData(gridData);
Tree tree = viewer.getTree();
// make the table header visible to see the column's text
tree.setHeaderVisible(true);
......@@ -106,6 +155,16 @@ public abstract class AbstractJFaceView extends ViewPart {
tree.addListener(SWT.Collapse, listener);
tree.addListener(SWT.Expand, listener);
addTreeViewerContextMenu(viewer);
List<TreeFilter> filterList = new ArrayList<TreeFilter>();
filterList.add(createFilter(viewer, operationCol, methodSearchText));
filterList.add(createFilter(viewer, componentCol, componentSearchText));
filterList.add(createFilter(viewer, containerCol, containerSearchText));
for (TreeFilter f : filterList) {
viewer.addFilter(f);
}
return viewer;
}
......@@ -118,17 +177,17 @@ public abstract class AbstractJFaceView extends ViewPart {
getSite().registerContextMenu(manager, viewer);
getSite().setSelectionProvider(viewer);
}
void createTreeViewerColumns(TreeViewer viewer, CallViewerComparator comparator, ColumnDef[] cols){
void createTreeViewerColumns(TreeViewer viewer, CallViewerComparator comparator, ColumnDef[] cols) {
int i = 0;
for(ColumnDef col : cols){
for (ColumnDef col : cols) {
createTreeViewerColumn(viewer, comparator, col.getStyle(), col.getName(), col.getWidth(),
col.getLabelProvider(), i++);
}
}
}
void createTreeViewerColumn(TreeViewer viewer, CallViewerComparator comparator, int style, String title,
int width, ColumnLabelProvider provider, int index) {
void createTreeViewerColumn(TreeViewer viewer, CallViewerComparator comparator, int style, String title, int width,
ColumnLabelProvider provider, int index) {
TreeViewerColumn viewCol = new TreeViewerColumn(viewer, style);
TreeColumn col = viewCol.getColumn();
col.setText(title);
......
......@@ -191,7 +191,7 @@ public class AnalysisTreeView extends AbstractJFaceView {
void createTraceTab() {
TabItem tab = new TabItem(tabFolder, SWT.NULL);
tab.setText(Messages.AnalysisTreeView_Traces);
TreeViewer viewer = createTree(tabFolder, tab);
TreeViewer viewer = createTree(tabFolder, tab, 1,2,3);
ColumnDef[] colDef = { new ColumnDef(Messages.AnalysisTreeView_TraceID, new TraceLabelProvider()),
new ColumnDef(Messages.AnalysisTreeView_Operation, new OperationLabelProvider()),
......@@ -212,14 +212,14 @@ public class AnalysisTreeView extends AbstractJFaceView {
viewer.setComparator(traceComp);
tabList.add(TRACETAB, tab);
viewerList.add(viewer);
viewerList.add(TRACETAB, viewer);
}
// aggregated traces tab
void createAggregatedTraceTab() {
TabItem tab = new TabItem(tabFolder, SWT.NULL);
tab.setText(Messages.AnalysisTreeView_AggregatedTraces);
TreeViewer viewer = createTree(tabFolder, tab);
TreeViewer viewer = createTree(tabFolder, tab,0,1,2);
ColumnDef[] colDef = { new ColumnDef(Messages.AnalysisTreeView_Operation, new OperationLabelProvider()),
new ColumnDef(Messages.AnalysisTreeView_Component, new ComponentLabelProvider()),
......@@ -243,14 +243,14 @@ public class AnalysisTreeView extends AbstractJFaceView {
viewer.setContentProvider(new TraceContentProvider());
viewer.setComparator(aggrTraceComp);
tabList.add(AGGRTRACETAB, tab);
viewerList.add(viewer);
viewerList.add(AGGRTRACETAB, viewer);
}
// operation call tab
void createOpCallTab() {
TabItem tab = new TabItem(tabFolder, SWT.NULL);
tab.setText(Messages.AnalysisTreeView_OpCalls);
TreeViewer viewer = createTree(tabFolder, tab);
TreeViewer viewer = createTree(tabFolder, tab,0,1,2);
ColumnDef[] colDef = { new ColumnDef(Messages.AnalysisTreeView_Operation, new OperationLabelProvider()),
new ColumnDef(Messages.AnalysisTreeView_Component, new ComponentLabelProvider()),
......@@ -268,14 +268,14 @@ public class AnalysisTreeView extends AbstractJFaceView {
viewer.setComparator(opCallComp);
tabList.add(OPCALLTAB, tab);
viewerList.add(viewer);
viewerList.add(OPCALLTAB, viewer);
}
// aggregated operational call tab
void createAggrOpCallTab() {
TabItem tab = new TabItem(tabFolder, SWT.NULL);
tab.setText(Messages.AnalysisTreeView_AggregatedOpCalls);
TreeViewer viewer = createTree(tabFolder, tab);
TreeViewer viewer = createTree(tabFolder, tab,0,1,2);
ColumnDef[] colDef = { new ColumnDef(Messages.AnalysisTreeView_Operation, new OperationLabelProvider()),
new ColumnDef(Messages.AnalysisTreeView_Component, new ComponentLabelProvider()),
new ColumnDef(Messages.AnalysisTreeView_Container, new ContainerLabelProvider()),
......@@ -295,7 +295,7 @@ public class AnalysisTreeView extends AbstractJFaceView {
viewer.setComparator(aggrOpCallComp);
tabList.add(AGGROPCALLTAB, tab);
viewerList.add(viewer);
viewerList.add(AGGROPCALLTAB, viewer);
}
// monitoring stats tab
......@@ -322,7 +322,7 @@ public class AnalysisTreeView extends AbstractJFaceView {
viewer.setContentProvider(ArrayContentProvider.getInstance());
tabList.add(MONITORINGSTATSTAB, tab);
viewerList.add(viewer);
viewerList.add(MONITORINGSTATSTAB, viewer);
}
public void setFocus(int tab) {
......
......@@ -26,6 +26,10 @@ public class Messages extends NLS {
public static String AnalysisTreeView_TraceID;
public static String AnalysisTreeView_Traces;
public static String AnalysisTreeView_FilterOperations;
public static String AnalysisTreeView_FilterComponents;
public static String AnalysisTreeView_FilterContainer;
public static String PluginPreferencesPage_GroupAppearance;
public static String PluginPreferencesPage_GroupAnalysis;
......
......@@ -35,4 +35,7 @@ PluginPreferencesPage_ComponentsShort=Short representation: Catalog
PluginPreferencesPage_ComponentsLong=Long representation: kieker.examples.bookstore.Catalog
PluginPreferencesPage_Components=Components
PluginPreferencesPage_AnalysisAdditional=Activate additional checks during trace reconstruction
PluginPreferencesPage_Timestamps=Timestamps
\ No newline at end of file
PluginPreferencesPage_Timestamps=Timestamps
AnalysisTreeView_FilterOperations=Filter Operations
AnalysisTreeView_FilterComponents=Filter Components
AnalysisTreeView_FilterContainer=Filter Container
\ No newline at end of file
......@@ -35,4 +35,7 @@ PluginPreferencesPage_Components=Komponenten
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
\ No newline at end of file
PluginPreferencesPage_Timestamps=Zeitstempel
AnalysisTreeView_FilterOperations=Filter Methoden
AnalysisTreeView_FilterComponents=Filter Komponenten
AnalysisTreeView_FilterContainer=Filter Container
\ 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