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

Added table sorting, corrected another issue

parent d52a623f
No related branches found
No related tags found
No related merge requests found
......@@ -120,6 +120,9 @@ public final class ExecutionEntry {
} else {
this.percent = 100.0f;
}
for (final ExecutionEntry executionEntry : this.children) {
executionEntry.updatePercent();
}
}
@Override
......
......@@ -25,12 +25,14 @@ import kieker.gui.model.Properties;
import kieker.gui.model.domain.AggregatedExecutionEntry;
import kieker.gui.model.domain.ExecutionEntry;
import kieker.gui.model.domain.RecordEntry;
import kieker.gui.view.util.AbstractDirectedComparator;
import kieker.gui.view.util.AggregatedExecutionTracesTreeSetDataListener;
import kieker.gui.view.util.ExecutionTracesTreeSetDataListener;
import kieker.gui.view.util.RecordEntryTimestampComparator;
import kieker.gui.view.util.RecordEntryTypeComparator;
import kieker.gui.view.util.RecordsTableSetDataListener;
import kieker.gui.view.util.TableColumnSortListener;
import kieker.gui.view.util.TreeColumnSortListener;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TreeViewer;
......@@ -364,6 +366,19 @@ public final class MainWindow {
this.recordsTableTypeColumn.addListener(SWT.Selection, new TableColumnSortListener<RecordEntry>(new RecordEntryTypeComparator()));
this.recordsTableRecordColumn.addListener(SWT.Selection, new TableColumnSortListener<RecordEntry>(new RecordEntryTimestampComparator()));
this.treeColumn_11.addListener(SWT.Selection, new TreeColumnSortListener(new AbstractDirectedComparator<ExecutionEntry>() {
@Override
public int compare(final ExecutionEntry arg0, final ExecutionEntry arg1) {
int result = Long.compare(arg0.getDuration(), arg1.getDuration());
if (this.getDirection() == SWT.UP) {
result = -result;
}
return result;
}
}));
this.explorerTree.addSelectionListener(new SelectionAdapter() {
@Override
......
package kieker.gui.view.util;
import java.util.Collections;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
public final class TreeColumnSortListener<T> implements Listener {
private final AbstractDirectedComparator<T> comparator;
public TreeColumnSortListener(final AbstractDirectedComparator<T> comparator) {
this.comparator = comparator;
}
@Override
public void handleEvent(final Event event) {
// Get the necessary information from the event
final TreeColumn currentColumn = (TreeColumn) event.widget;
final Tree tree = currentColumn.getParent();
final TreeColumn sortColumn = tree.getSortColumn();
// Determine new sort column and direction
int direction = tree.getSortDirection();
if (sortColumn == currentColumn) {
direction = ((direction == SWT.UP) ? SWT.DOWN : SWT.UP);
} else {
tree.setSortColumn(currentColumn);
direction = SWT.UP;
}
// Sort the data
this.comparator.setDirection(direction);
final List<T> entries = (List<T>) tree.getData();
Collections.sort(entries, this.comparator);
// Update the data displayed in the table
tree.setSortDirection(direction);
tree.clearAll(true);
}
}
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