Commit 05b71727 authored by Florian's avatar Florian

refactoring and improved open file handler

parent f74d77db
......@@ -56,7 +56,7 @@
name="Handler"
point="org.eclipse.ui.handlers">
<handler
class="kieker.tools.eclipse.analysis.handler.TraceTreeViewHandler"
class="kieker.tools.eclipse.analysis.handler.folder.TraceTreeViewHandler"
commandId="kieker.tools.eclipse.analysis.commands.showTracesCommand">
<enabledWhen>
<with
......@@ -75,7 +75,7 @@
</enabledWhen>
</handler>
<handler
class="kieker.tools.eclipse.analysis.handler.AggregatedTraceTreeViewHandler"
class="kieker.tools.eclipse.analysis.handler.folder.AggregatedTraceTreeViewHandler"
commandId="kieker.tools.eclipse.analysis.commands.showAggregatedTracesCommand">
<enabledWhen>
<with variable="activeMenuSelection">
......@@ -92,7 +92,7 @@
</enabledWhen>
</handler>
<handler
class="kieker.tools.eclipse.analysis.handler.OperationCallTreeViewHandler"
class="kieker.tools.eclipse.analysis.handler.folder.OperationCallTreeViewHandler"
commandId="kieker.tools.eclipse.analysis.commands.showOperationCallsCommand">
<enabledWhen>
<with variable="activeMenuSelection">
......@@ -109,7 +109,7 @@
</enabledWhen>
</handler>
<handler
class="kieker.tools.eclipse.analysis.handler.AggregatedOperationCallTreeViewHandler"
class="kieker.tools.eclipse.analysis.handler.folder.AggregatedOperationCallTreeViewHandler"
commandId="kieker.tools.eclipse.analysis.commands.showAggregatedOperationCallsCommand">
<enabledWhen>
<with
......@@ -140,7 +140,7 @@
</enabledWhen>
</handler>
<handler
class="kieker.tools.eclipse.analysis.handler.ShowMonitoringLogsHandler"
class="kieker.tools.eclipse.analysis.handler.folder.ShowMonitoringLogsHandler"
commandId="kieker.tools.eclipse.analysis.commands.showMonitoringStatsCommand">
<enabledWhen>
<with
......@@ -158,11 +158,11 @@
</enabledWhen>
</handler>
<handler
class="kieker.tools.eclipse.analysis.handler.SelectTraceFromOpCallHandler"
class="kieker.tools.eclipse.analysis.handler.view.SelectTraceFromOpCallHandler"
commandId="kieker.tools.eclipse.analysis.commands.selectTraceFromOpCallCommand">
</handler>
<handler
class="kieker.tools.eclipse.analysis.handler.SelectOpCallsFromAggregatedOpCallHandler"
class="kieker.tools.eclipse.analysis.handler.view.SelectOpCallsFromAggregatedOpCallHandler"
commandId="kieker.tools.eclipse.analysis.commands.selectOpCallFromAggrOpCallCommand">
</handler>
</extension>
......@@ -261,21 +261,21 @@
<extension
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
class="kieker.tools.eclipse.analysis.helper.KiekerLogFolderTester"
class="kieker.tools.eclipse.analysis.tester.KiekerLogFolderTester"
id="kieker.tools.eclipse.analysis.helper.kiekerLogFolderTester"
namespace="kieker.tools.eclipse.analysis.helper.kiekerLogFolderTester"
properties="checkFolder"
type="org.eclipse.core.resources.IResource">
</propertyTester>
<propertyTester
class="kieker.tools.eclipse.analysis.helper.OpCallTabTester"
class="kieker.tools.eclipse.analysis.tester.OpCallTabTester"
id="kieker.tools.eclipse.analysis.helper.opCallTabTester"
namespace="kieker.tools.eclipse.analysis.helper.opCallTabTester"
properties="checkOpCallTab"
type="kieker.analysis.domain.OperationCall">
</propertyTester>
<propertyTester
class="kieker.tools.eclipse.analysis.helper.OpCallTabTester"
class="kieker.tools.eclipse.analysis.tester.OpCallTabTester"
id="kieker.tools.eclipse.analysis.helper.aggrOpCallTabTester"
namespace="kieker.tools.eclipse.analysis.helper.aggrOpCallTabTester"
properties="checkAggrOpCallTab"
......
......@@ -32,19 +32,19 @@ import kieker.tools.eclipse.analysis.provider.DataProvider;
public class OpenFileHandler extends AbstractHandler {
IType type;
IProject project; // TODO need to set project...
IProject project;
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection sel = HandlerUtil.getCurrentSelection(event);
if (sel instanceof IStructuredSelection) {
Object selected= ((IStructuredSelection) sel).getFirstElement();
Object selected = ((IStructuredSelection) sel).getFirstElement();
project = DataProvider.getProject();
openFile(selected);
}
}
return null;
}
private void openFile(Object selectedNode) {
if (project != null) {
String component = null;
......@@ -63,34 +63,34 @@ public class OpenFileHandler extends AbstractHandler {
try {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IFile file = getFile(component);
if(file == null)
if (file == null)
return;
IEditorPart editorPart = IDE.openEditor(page, file);
highlightCodeline(editorPart, component, operation);
highlightCodeline(editorPart, operation);
} catch (CoreException e) {
e.printStackTrace();
}
}
}
}
private IFile getFile(String filename) {
try {
IJavaProject javaProject = JavaCore.create(project);
if(javaProject != null)
if (javaProject != null)
type = javaProject.findType(filename);
IPath path = null;
if(type != null)
if (type != null)
path = type.getPath();
if(path != null)
if (path != null)
return ResourcesPlugin.getWorkspace().getRoot().getFile(path);
} catch (JavaModelException e) {
e.printStackTrace();
}
return null;
}
private void highlightCodeline(IEditorPart editorPart, String component, String operation) {
private void highlightCodeline(IEditorPart editorPart, String operation) {
if (editorPart instanceof ITextEditor) {
ITextEditor editor = (ITextEditor) editorPart;
IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
......@@ -102,42 +102,54 @@ public class OpenFileHandler extends AbstractHandler {
e1.printStackTrace();
}
operation = operation.replace(component + ".", "");
String parameter = operation.substring(operation.indexOf("("), operation.length());
parameter = parameter.replace("(", "").replace(")", "").replace(" ", "");
String[] parameters;
if (parameter.equals("")) {
parameters = new String[0];
} else {
parameters = parameter.split(",");
}
int length = 0;
int offset = 0;
operation = operation.substring(0, operation.indexOf("("));
String method = operation.substring(operation.lastIndexOf(".") + 1, operation.length());
String returnType = operation.substring(0, operation.lastIndexOf(" "));
returnType = returnType.substring(returnType.lastIndexOf(" ") + 1, returnType.length());
returnType = returnType.substring(returnType.lastIndexOf(".") + 1, returnType.length());
for (IMethod meth : methArray) {
methodloop: for (IMethod meth : methArray) {
try {
boolean hasName = operation.contains(meth.getElementName());
if(!hasName)
boolean hasName = method.contains(meth.getElementName());
String returnTypeMeth = Signature.getSignatureSimpleName(meth.getReturnType());
hasName &= returnTypeMeth.contains(returnType);
if (!hasName)
continue;
boolean hasParams = true;
String[] parameters = meth.getParameterTypes();
String[] parametersMeth = meth.getParameterTypes();
if (parameters.length != parametersMeth.length)
continue;
for (String param : parameters) {
param = Signature.getSignatureSimpleName(param);
int index = param.indexOf("<");
if(index > 0){
param = param.substring(0, index);
param = param.substring(param.lastIndexOf(".") + 1, param.length());
boolean contains = false;
for (String paramMeth : parametersMeth) {
paramMeth = Signature.getSignatureSimpleName(paramMeth);
contains |= paramMeth.contains(param);
}
if (!operation.contains(param)) {
hasParams = false;
}
}
if (hasName && hasParams) {
length = meth.getSourceRange().getLength();
offset = meth.getSourceRange().getOffset();
break;
if (!contains)
continue methodloop;
}
editor.selectAndReveal(meth.getSourceRange().getOffset(), meth.getSourceRange().getLength());
break;
} catch (JavaModelException e) {
e.printStackTrace();
}
}
editor.selectAndReveal(offset, length);
}
}
}
......
package kieker.tools.eclipse.analysis.handler;
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.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
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.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 {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
try {
IViewPart partView = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage()
.showView(AnalysisTreeView.VIEWNAME);
ISelection sel = HandlerUtil.getCurrentSelection(event);
if (sel instanceof IStructuredSelection) {
Object selected = ((IStructuredSelection) sel).getFirstElement();
if (selected instanceof AggregatedOperationCall) {
AggregatedOperationCall aggrOpCall = (AggregatedOperationCall) selected;
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<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.handler;
package kieker.tools.eclipse.analysis.handler.folder;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
......
package kieker.tools.eclipse.analysis.handler;
package kieker.tools.eclipse.analysis.handler.folder;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.ui.IViewPart;
......
package kieker.tools.eclipse.analysis.handler;
import java.util.ArrayList;
import java.util.List;
package kieker.tools.eclipse.analysis.handler.view;
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.ui.IViewPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.handlers.HandlerUtil;
import kieker.analysis.domain.OperationCall;
import kieker.tools.eclipse.analysis.view.AnalysisTreeView;
public class SelectTraceFromOpCallHandler extends AbstractHandler {
public abstract class AbstractViewHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
......@@ -28,30 +21,17 @@ public class SelectTraceFromOpCallHandler extends AbstractHandler {
ISelection sel = HandlerUtil.getCurrentSelection(event);
if (sel instanceof IStructuredSelection) {
Object selected= ((IStructuredSelection) sel).getFirstElement();
if (selected instanceof OperationCall) {
OperationCall opCall = (OperationCall) selected;
List<Object> path = new ArrayList<>();
path.add(opCall);
if (partView instanceof AnalysisTreeView) {
AnalysisTreeView view = (AnalysisTreeView) partView;
List<ColumnViewer> viewer = view.getViewerList();
ColumnViewer colView = viewer.get(AnalysisTreeView.TRACETAB);
colView.setSelection(new TreeSelection(new TreePath(path.toArray())), true);
view.setFocus(AnalysisTreeView.TRACETAB);
}
}
Object selected= ((IStructuredSelection) sel).getFirstElement();
execute(selected, partView);
}
} catch (PartInitException e) {
e.printStackTrace();
}
return null;
}
public abstract void execute(Object selected, IViewPart partView);
}
package kieker.tools.eclipse.analysis.handler.view;
import java.util.List;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IViewPart;
import kieker.analysis.domain.AggregatedOperationCall;
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 AbstractViewHandler {
@Override
public void execute(Object selected, IViewPart partView) {
if (selected instanceof AggregatedOperationCall) {
AggregatedOperationCall aggrOpCall = (AggregatedOperationCall) selected;
String container = new ContainerLabelProvider().getString(aggrOpCall);
String component = new ComponentLabelProvider().getString(aggrOpCall);
String operation = new OperationLabelProvider().getString(aggrOpCall);
if (partView instanceof AnalysisTreeView) {
AnalysisTreeView view = (AnalysisTreeView) partView;
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);
}
}
}
}
package kieker.tools.eclipse.analysis.handler.view;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.viewers.ColumnViewer;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeSelection;
import org.eclipse.ui.IViewPart;
import kieker.analysis.domain.OperationCall;
import kieker.tools.eclipse.analysis.view.AnalysisTreeView;
public class SelectTraceFromOpCallHandler extends AbstractViewHandler {
@Override
public void execute(Object selected, IViewPart partView){
if (selected instanceof OperationCall) {
OperationCall opCall = (OperationCall) selected;
List<Object> path = new ArrayList<>();
path.add(opCall);
if (partView instanceof AnalysisTreeView) {
AnalysisTreeView view = (AnalysisTreeView) partView;
List<ColumnViewer> viewer = view.getViewerList();
ColumnViewer colView = viewer.get(AnalysisTreeView.TRACETAB);
colView.setSelection(new TreeSelection(new TreePath(path.toArray())), true);
view.setFocus(AnalysisTreeView.TRACETAB);
}
}
}
}
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);
}
}
package kieker.tools.eclipse.analysis.helper;
package kieker.tools.eclipse.analysis.listener;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.events.ModifyEvent;
......@@ -6,6 +6,8 @@ import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.TreeColumn;
import kieker.tools.eclipse.analysis.helper.TreeFilter;
public class FilterModifyListener implements ModifyListener {
TreeViewer viewer;
......
......@@ -18,6 +18,7 @@ import kieker.analysis.domain.Trace;
import kieker.common.record.misc.KiekerMetadataRecord;
import kieker.tools.eclipse.analysis.Activator;
import kieker.tools.eclipse.analysis.model.Properties;
import kieker.tools.eclipse.analysis.resources.provider.Messages;
import kieker.tools.util.LoggingTimestampConverter;
import teetime.framework.Execution;
......
package kieker.tools.eclipse.analysis.provider;
package kieker.tools.eclipse.analysis.resources.provider;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "kieker.tools.eclipse.analysis.provider.messages"; //$NON-NLS-1$
private static final String BUNDLE_NAME = "kieker.tools.eclipse.analysis.resources.provider.messages"; //$NON-NLS-1$
public static String MonitoringStats_AggregatedOperationCall;
public static String MonitoringStats_AggregatedTraces;
public static String MonitoringStats_DanglingTraces;
......
package kieker.tools.eclipse.analysis.view;
package kieker.tools.eclipse.analysis.resources.view;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "kieker.tools.eclipse.analysis.view.messages"; //$NON-NLS-1$
private static final String BUNDLE_NAME = "kieker.tools.eclipse.analysis.resources.view.messages"; //$NON-NLS-1$
public static String AnalysisTreeView_AggregatedOpCalls;
public static String AnalysisTreeView_AggregatedTraces;
public static String AnalysisTreeView_Calls;
......
package kieker.tools.eclipse.analysis.helper;
package kieker.tools.eclipse.analysis.tester;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.resources.IFolder;
......
package kieker.tools.eclipse.analysis.helper;
package kieker.tools.eclipse.analysis.tester;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.swt.widgets.TabFolder;
......
......@@ -40,9 +40,10 @@ import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.part.ViewPart;
import kieker.tools.eclipse.analysis.comparator.CallViewerComparator;
import kieker.tools.eclipse.analysis.helper.FilterModifyListener;
import kieker.tools.eclipse.analysis.helper.TreeFilter;
import kieker.tools.eclipse.analysis.listener.FilterModifyListener;
import kieker.tools.eclipse.analysis.model.ColumnDef;
import kieker.tools.eclipse.analysis.resources.view.Messages;
public abstract class AbstractJFaceView extends ViewPart {
......
......@@ -32,7 +32,7 @@ import kieker.tools.eclipse.analysis.comparator.AggregatedOperationCallViewerCom
import kieker.tools.eclipse.analysis.comparator.AggregatedTraceViewerComparator;
import kieker.tools.eclipse.analysis.comparator.OperationCallViewerComparator;
import kieker.tools.eclipse.analysis.comparator.TraceViewerComparator;
import kieker.tools.eclipse.analysis.helper.FilterModifyListener;
import kieker.tools.eclipse.analysis.listener.FilterModifyListener;
import kieker.tools.eclipse.analysis.model.ColumnDef;
import kieker.tools.eclipse.analysis.model.Properties;
import kieker.tools.eclipse.analysis.provider.DataProvider;
......@@ -56,6 +56,7 @@ import kieker.tools.eclipse.analysis.provider.label.StringArrayLabelProvider;
import kieker.tools.eclipse.analysis.provider.label.TimestampLabelProvider;
import kieker.tools.eclipse.analysis.provider.label.TotalDurationLabelProvider;
import kieker.tools.eclipse.analysis.provider.label.TraceLabelProvider;
import kieker.tools.eclipse.analysis.resources.view.Messages;
public class AnalysisTreeView extends AbstractJFaceView {
......
......@@ -14,6 +14,7 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
import kieker.tools.eclipse.analysis.Activator;
import kieker.tools.eclipse.analysis.model.Properties;
import kieker.tools.eclipse.analysis.resources.view.Messages;
public class PluginPreferencesPage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
......
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