Skip to content
Snippets Groups Projects
Commit 40593c42 authored by Nils Christian Ehmke's avatar Nils Christian Ehmke
Browse files

Started with the presentation of (aggregated) calls

parent db5eef35
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@ import kieker.diagnosis.common.domain.OperationCall;
import kieker.diagnosis.common.domain.Trace;
import kieker.diagnosis.common.model.DataModel;
import kieker.diagnosis.common.model.PropertiesModel;
import kieker.diagnosis.subview.Filter;
import kieker.diagnosis.subview.ISubController;
import kieker.diagnosis.subview.ISubView;
import kieker.diagnosis.subview.util.AbstractDataModelProxy;
......@@ -32,7 +33,7 @@ import org.eclipse.swt.events.SelectionListener;
/**
* The sub-controller responsible for the sub-view presenting the available traces.
*
*
* @author Nils Christian Ehmke
*/
public final class Controller implements ISubController, SelectionListener {
......@@ -40,7 +41,7 @@ public final class Controller implements ISubController, SelectionListener {
private final ISubView view;
private final Model model;
public Controller(final Type filter, final DataModel dataModel, final PropertiesModel propertiesModel) {
public Controller(final Filter filter, final DataModel dataModel, final PropertiesModel propertiesModel) {
final IModel<Trace> modelProxy = Controller.createModelProxy(dataModel, filter);
this.model = new Model();
......@@ -64,20 +65,16 @@ public final class Controller implements ISubController, SelectionListener {
// Just implemented for the interface
}
private static IModel<Trace> createModelProxy(final DataModel dataModel, final Type filter) {
if (filter == Type.JUST_FAILED_TRACES) {
private static IModel<Trace> createModelProxy(final DataModel dataModel, final Filter filter) {
if (filter == Filter.JUST_FAILED) {
return new FailedTracesModelProxy(dataModel);
}
if (filter == Type.JUST_FAILURE_CONTAINING_TRACES) {
if (filter == Filter.JUST_FAILURE_CONTAINING) {
return new FailureContainingTracesModelProxy(dataModel);
}
return new TracesModelProxy(dataModel);
}
public enum Type {
NONE, JUST_FAILED_TRACES, JUST_FAILURE_CONTAINING_TRACES
}
private static final class TracesModelProxy extends AbstractDataModelProxy<Trace> {
public TracesModelProxy(final DataModel dataModel) {
......
/***************************************************************************
* Copyright 2014 Kieker Project (http://kieker-monitoring.net)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/
package kieker.diagnosis.subview.util;
import java.io.Serializable;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import kieker.diagnosis.common.domain.AbstractOperationCall;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
public abstract class AbstractCallTableColumnSortListener<T extends AbstractOperationCall<?>> extends SelectionAdapter implements Serializable {
private static final long serialVersionUID = 1L;
private final CallComparator comparator = new CallComparator();
private int direction;
@Override
@SuppressWarnings("unchecked")
public final void widgetSelected(final SelectionEvent event) {
// Get the necessary information from the event
final TableColumn currentColumn = (TableColumn) event.widget;
final Table table = currentColumn.getParent();
final TableColumn sortColumn = table.getSortColumn();
// Determine new sort column and direction
this.direction = table.getSortDirection();
if (sortColumn == currentColumn) {
this.direction = ((this.direction == SWT.UP) ? SWT.DOWN : SWT.UP);
} else {
table.setSortColumn(currentColumn);
this.direction = SWT.UP;
}
// Sort the data
final List<T> entries = (List<T>) table.getData();
Collections.sort(entries, this.comparator);
// Update the data displayed in the table
table.setSortDirection(this.direction);
table.clearAll();
}
protected abstract int compare(final T fstCall, final T sndCall);
private final class CallComparator implements Comparator<T>, Serializable {
private static final long serialVersionUID = 1L;
@Override
public int compare(final T fstCall, final T sndCall) {
int result;
if (AbstractCallTableColumnSortListener.this.direction == SWT.DOWN) {
result = AbstractCallTableColumnSortListener.this.compare(fstCall, sndCall);
} else {
result = AbstractCallTableColumnSortListener.this.compare(sndCall, fstCall);
}
return result;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment