From 692584a7c064a30d21627c2cea86500f568db923 Mon Sep 17 00:00:00 2001 From: Nils Christian Ehmke <nie@informatik.uni-kiel.de> Date: Mon, 8 Dec 2014 14:37:21 +0100 Subject: [PATCH] Moved internal classes to own files --- .../importer/filter/TraceAggregator.java | 1 - ...tedExecutionTracesTreeSetDataListener.java | 55 +++ .../ExecutionTraceTreeSelectionListener.java | 61 ++++ .../ExecutionTracesTreeSetDataListener.java | 61 ++++ .../view/ExplorerTreeSelectionAdapter.java | 37 ++ src/main/java/kieker/gui/view/MainWindow.java | 323 +----------------- .../view/RecordEntryTimestampComparator.java | 26 ++ .../gui/view/RecordEntryTypeComparator.java | 25 ++ .../gui/view/RecordsTableSetDataListener.java | 32 ++ .../RecordsTableTimestampSortListener.java | 40 +++ .../view/RecordsTableTypeSortListener.java | 40 +++ .../kieker/gui/view/TreeUpdateObserver.java | 21 ++ 12 files changed, 413 insertions(+), 309 deletions(-) create mode 100644 src/main/java/kieker/gui/view/AggregatedExecutionTracesTreeSetDataListener.java create mode 100644 src/main/java/kieker/gui/view/ExecutionTraceTreeSelectionListener.java create mode 100644 src/main/java/kieker/gui/view/ExecutionTracesTreeSetDataListener.java create mode 100644 src/main/java/kieker/gui/view/ExplorerTreeSelectionAdapter.java create mode 100644 src/main/java/kieker/gui/view/RecordEntryTimestampComparator.java create mode 100644 src/main/java/kieker/gui/view/RecordEntryTypeComparator.java create mode 100644 src/main/java/kieker/gui/view/RecordsTableSetDataListener.java create mode 100644 src/main/java/kieker/gui/view/RecordsTableTimestampSortListener.java create mode 100644 src/main/java/kieker/gui/view/RecordsTableTypeSortListener.java create mode 100644 src/main/java/kieker/gui/view/TreeUpdateObserver.java diff --git a/src/main/java/kieker/gui/model/importer/filter/TraceAggregator.java b/src/main/java/kieker/gui/model/importer/filter/TraceAggregator.java index a0ec2f10..22f72ea5 100644 --- a/src/main/java/kieker/gui/model/importer/filter/TraceAggregator.java +++ b/src/main/java/kieker/gui/model/importer/filter/TraceAggregator.java @@ -43,7 +43,6 @@ public final class TraceAggregator extends AbstractConsumerStage<ExecutionEntry> @Override public void onTerminating() throws Exception { - System.out.println("onTerminating"); for (final AggregatedExecutionEntry aggregatedExecutionEntry : this.aggregationMap.values()) { this.outputPort.send(aggregatedExecutionEntry); } diff --git a/src/main/java/kieker/gui/view/AggregatedExecutionTracesTreeSetDataListener.java b/src/main/java/kieker/gui/view/AggregatedExecutionTracesTreeSetDataListener.java new file mode 100644 index 00000000..b6d1bb6b --- /dev/null +++ b/src/main/java/kieker/gui/view/AggregatedExecutionTracesTreeSetDataListener.java @@ -0,0 +1,55 @@ +package kieker.gui.view; + +import java.util.List; + +import kieker.gui.model.AggregatedExecutionEntry; +import kieker.gui.model.Properties; + +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.TreeItem; + +class AggregatedExecutionTracesTreeSetDataListener implements Listener { + + @Override + public void handleEvent(final Event event) { + // Get the necessary information from the event + final Tree tree = (Tree) event.widget; + final TreeItem item = (TreeItem) event.item; + final int tableIndex = event.index; + final TreeItem parent = item.getParentItem(); + + // Decide whether the current item is a root or not + final AggregatedExecutionEntry executionEntry; + if (parent == null) { + executionEntry = ((List<AggregatedExecutionEntry>) tree.getData()).get(tableIndex); + } else { + // executionEntry = ((AggregatedExecutionEntry) parent.getData()).getChildren().get(tableIndex); + executionEntry = null; + } + + String componentName = executionEntry.getComponent(); + if (Properties.getInstance().isShortComponentNames()) { + final int lastPointPos = componentName.lastIndexOf('.'); + componentName = componentName.substring(lastPointPos + 1); + } + String operationString = executionEntry.getOperation(); + if (Properties.getInstance().isShortOperationParameters()) { + operationString = operationString.replaceAll("\\(..*\\)", "(...)"); + + final int lastPointPos = operationString.lastIndexOf('.', operationString.length() - 5); + operationString = operationString.substring(lastPointPos + 1); + } + item.setText(new String[] { executionEntry.getContainer(), componentName, operationString, Integer.toString(executionEntry.getCalls()) }); + + // if (executionEntry.isFailed()) { + // final Color colorRed = Display.getCurrent().getSystemColor(SWT.COLOR_RED); + // item.setForeground(colorRed); + // } + + item.setData(executionEntry); + item.setItemCount(0); + // item.setItemCount(executionEntry.getChildren().size()); + } +} \ No newline at end of file diff --git a/src/main/java/kieker/gui/view/ExecutionTraceTreeSelectionListener.java b/src/main/java/kieker/gui/view/ExecutionTraceTreeSelectionListener.java new file mode 100644 index 00000000..170ec8d7 --- /dev/null +++ b/src/main/java/kieker/gui/view/ExecutionTraceTreeSelectionListener.java @@ -0,0 +1,61 @@ +package kieker.gui.view; + +import kieker.gui.model.ExecutionEntry; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.widgets.Display; + +class ExecutionTraceTreeSelectionListener implements SelectionListener { + + /** + * + */ + private final MainWindow mainWindow; + + /** + * @param mainWindow + */ + ExecutionTraceTreeSelectionListener(MainWindow mainWindow) { + this.mainWindow = mainWindow; + } + + @Override + public void widgetSelected(final SelectionEvent e) { + final Object data = e.item.getData(); + if (data instanceof ExecutionEntry) { + this.mainWindow.lblNa_1.setText(Long.toString(((ExecutionEntry) data).getTraceID())); + this.mainWindow.lblNa_3.setText(Long.toString(((ExecutionEntry) data).getDuration())); + + this.mainWindow.lblNa_4.setText(((ExecutionEntry) data).getContainer()); + this.mainWindow.lblNa_5.setText(((ExecutionEntry) data).getComponent()); + this.mainWindow.lblNa_6.setText(((ExecutionEntry) data).getOperation()); + this.mainWindow.lblNa_7.setText(Integer.toString(((ExecutionEntry) data).getStackDepth())); + + if (((ExecutionEntry) data).isFailed()) { + this.mainWindow.lblNa_2.setText("Yes (" + ((ExecutionEntry) data).getFailedCause() + ")"); + this.mainWindow.lblNa_2.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); + this.mainWindow.lblFailed.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); + } else { + this.mainWindow.lblNa_2.setText("No"); + this.mainWindow.lblNa_2.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); + this.mainWindow.lblFailed.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); + } + + this.mainWindow.lblNa_1.pack(); + this.mainWindow.lblNa_2.pack(); + this.mainWindow.lblNa_3.pack(); + this.mainWindow.lblNa_4.pack(); + this.mainWindow.lblNa_5.pack(); + this.mainWindow.lblNa_6.pack(); + this.mainWindow.lblNa_7.pack(); + } + } + + @Override + public void widgetDefaultSelected(final SelectionEvent e) { + + } + +} \ No newline at end of file diff --git a/src/main/java/kieker/gui/view/ExecutionTracesTreeSetDataListener.java b/src/main/java/kieker/gui/view/ExecutionTracesTreeSetDataListener.java new file mode 100644 index 00000000..ca8bf61b --- /dev/null +++ b/src/main/java/kieker/gui/view/ExecutionTracesTreeSetDataListener.java @@ -0,0 +1,61 @@ +package kieker.gui.view; + +import java.util.List; + +import kieker.gui.model.ExecutionEntry; +import kieker.gui.model.Properties; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.TreeItem; + +class ExecutionTracesTreeSetDataListener implements Listener { + + @Override + public void handleEvent(final Event event) { + // Get the necessary information from the event + final Tree tree = (Tree) event.widget; + final TreeItem item = (TreeItem) event.item; + final int tableIndex = event.index; + final TreeItem parent = item.getParentItem(); + + // Decide whether the current item is a root or not + final ExecutionEntry executionEntry; + final String traceID; + + if (parent == null) { + executionEntry = ((List<ExecutionEntry>) tree.getData()).get(tableIndex); + traceID = Long.toString(executionEntry.getTraceID()); + } else { + executionEntry = ((ExecutionEntry) parent.getData()).getChildren().get(tableIndex); + traceID = ""; + } + + String componentName = executionEntry.getComponent(); + if (Properties.getInstance().isShortComponentNames()) { + final int lastPointPos = componentName.lastIndexOf('.'); + componentName = componentName.substring(lastPointPos + 1); + } + String operationString = executionEntry.getOperation(); + if (Properties.getInstance().isShortOperationParameters()) { + operationString = operationString.replaceAll("\\(..*\\)", "(...)"); + + final int lastPointPos = operationString.lastIndexOf('.', operationString.length() - 5); + operationString = operationString.substring(lastPointPos + 1); + } + item.setText(new String[] { executionEntry.getContainer(), componentName, operationString, Long.toString(executionEntry.getDuration()), + String.format("%.1f%%", executionEntry.getPercent()), traceID }); + + if (executionEntry.isFailed()) { + final Color colorRed = Display.getCurrent().getSystemColor(SWT.COLOR_RED); + item.setForeground(colorRed); + } + + item.setData(executionEntry); + item.setItemCount(executionEntry.getChildren().size()); + } +} \ No newline at end of file diff --git a/src/main/java/kieker/gui/view/ExplorerTreeSelectionAdapter.java b/src/main/java/kieker/gui/view/ExplorerTreeSelectionAdapter.java new file mode 100644 index 00000000..3d2ed9fc --- /dev/null +++ b/src/main/java/kieker/gui/view/ExplorerTreeSelectionAdapter.java @@ -0,0 +1,37 @@ +package kieker.gui.view; + +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.widgets.Widget; + +class ExplorerTreeSelectionAdapter extends SelectionAdapter { + + /** + * + */ + private final MainWindow mainWindow; + + /** + * @param mainWindow + */ + ExplorerTreeSelectionAdapter(MainWindow mainWindow) { + this.mainWindow = mainWindow; + } + + @Override + public void widgetSelected(final SelectionEvent e) { + final Widget selectedWidget = e.item; + + if (this.mainWindow.recordsTreeItem == selectedWidget) { + this.mainWindow.showRecords(); + } else if (this.mainWindow.executionTracesTreeItem == selectedWidget) { + this.mainWindow.showExecutionTraces(); + } else if (this.mainWindow.trtmAggregatedExecutionTraces == selectedWidget) { + this.mainWindow.showAggregatedExecutionTraces(); + } else { + this.mainWindow.setVisibleMainComponent(null); + this.mainWindow.lblNa.setText(""); + } + } + +} \ No newline at end of file diff --git a/src/main/java/kieker/gui/view/MainWindow.java b/src/main/java/kieker/gui/view/MainWindow.java index 04c39182..22c3be9d 100644 --- a/src/main/java/kieker/gui/view/MainWindow.java +++ b/src/main/java/kieker/gui/view/MainWindow.java @@ -16,13 +16,8 @@ package kieker.gui.view; -import java.util.Collections; -import java.util.Comparator; import java.util.List; -import java.util.Observable; -import java.util.Observer; -import kieker.common.record.IMonitoringRecord; import kieker.gui.model.AggregatedExecutionEntry; import kieker.gui.model.DataSource; import kieker.gui.model.ExecutionEntry; @@ -36,27 +31,21 @@ import org.eclipse.swt.custom.SashForm; import org.eclipse.swt.custom.StackLayout; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Color; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeColumn; import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.swt.widgets.Widget; import org.eclipse.wb.swt.SWTResourceManager; /** @@ -72,8 +61,8 @@ public class MainWindow { private SashForm outerForm; private TreeViewer explorerTreeViewer; private TreeItem explorerTreeItem; - private TreeItem recordsTreeItem; - private TreeItem executionTracesTreeItem; + TreeItem recordsTreeItem; + TreeItem executionTracesTreeItem; private TableViewer recordsTableViewer; private TableColumn recordsTableTimestampColumn; private TableColumn recordsTableRecordColumn; @@ -102,23 +91,23 @@ public class MainWindow { private SashForm explorerForm; private final DataSource model = new DataSource(); private TreeColumn trclmnPercent; - private Label lblNa; + Label lblNa; private SashForm executionTracesForm; private Composite executionTracesDetailComposite; private Label lblTraceId; - private Label lblNa_1; - private Label lblFailed; - private Label lblNa_2; + Label lblNa_1; + Label lblFailed; + Label lblNa_2; private Label lblDuration; - private Label lblNa_3; + Label lblNa_3; private Label lblExecutionContainer; private Label lblComponent; private Label lblOperation; - private Label lblNa_4; - private Label lblNa_5; - private Label lblNa_6; + Label lblNa_4; + Label lblNa_5; + Label lblNa_6; private Label lblStackDepth; - private Label lblNa_7; + Label lblNa_7; private SashForm sashForm; private Tree tree_1; private TreeColumn treeColumn; @@ -136,7 +125,7 @@ public class MainWindow { private Label label_11; private Label label_12; private Label label_13; - private TreeItem trtmAggregatedExecutionTraces; + TreeItem trtmAggregatedExecutionTraces; public static void main(final String[] args) { final MainWindow window = new MainWindow(); @@ -186,7 +175,7 @@ public class MainWindow { this.executionTracesTreeItem.setExpanded(true); this.explorerTreeItem.setExpanded(true); - this.explorerTree.addSelectionListener(new ExplorerTreeSelectionAdapter()); + this.explorerTree.addSelectionListener(new ExplorerTreeSelectionAdapter(this)); this.explorerForm.setWeights(new int[] { 3 }); this.mainComposite = new Composite(this.outerForm, SWT.NONE); @@ -218,7 +207,7 @@ public class MainWindow { this.executionTracesTree = new Tree(this.executionTracesForm, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL); this.executionTracesTree.setHeaderVisible(true); this.executionTracesTree.addListener(SWT.SetData, new ExecutionTracesTreeSetDataListener()); - this.executionTracesTree.addSelectionListener(new ExecutionTraceTreeSelectionListener()); + this.executionTracesTree.addSelectionListener(new ExecutionTraceTreeSelectionListener(this)); Properties.getInstance().addObserver(new TreeUpdateObserver(this.executionTracesTree)); this.tracesTreeContainerColumn = new TreeColumn(this.executionTracesTree, SWT.NONE); @@ -538,292 +527,10 @@ public class MainWindow { } } - private void setVisibleMainComponent(final Control component) { + void setVisibleMainComponent(final Control component) { final StackLayout layout = (StackLayout) this.mainComposite.getLayout(); layout.topControl = component; this.mainComposite.layout(); } - - private class ExplorerTreeSelectionAdapter extends SelectionAdapter { - - @Override - public void widgetSelected(final SelectionEvent e) { - final Widget selectedWidget = e.item; - - if (MainWindow.this.recordsTreeItem == selectedWidget) { - MainWindow.this.showRecords(); - } else if (MainWindow.this.executionTracesTreeItem == selectedWidget) { - MainWindow.this.showExecutionTraces(); - } else if (MainWindow.this.trtmAggregatedExecutionTraces == selectedWidget) { - MainWindow.this.showAggregatedExecutionTraces(); - } else { - MainWindow.this.setVisibleMainComponent(null); - MainWindow.this.lblNa.setText(""); - } - } - - } - - private class AggregatedExecutionTracesTreeSetDataListener implements Listener { - - @Override - public void handleEvent(final Event event) { - // Get the necessary information from the event - final Tree tree = (Tree) event.widget; - final TreeItem item = (TreeItem) event.item; - final int tableIndex = event.index; - final TreeItem parent = item.getParentItem(); - - // Decide whether the current item is a root or not - final AggregatedExecutionEntry executionEntry; - if (parent == null) { - executionEntry = ((List<AggregatedExecutionEntry>) tree.getData()).get(tableIndex); - } else { - // executionEntry = ((AggregatedExecutionEntry) parent.getData()).getChildren().get(tableIndex); - executionEntry = null; - } - - String componentName = executionEntry.getComponent(); - if (Properties.getInstance().isShortComponentNames()) { - final int lastPointPos = componentName.lastIndexOf('.'); - componentName = componentName.substring(lastPointPos + 1); - } - String operationString = executionEntry.getOperation(); - if (Properties.getInstance().isShortOperationParameters()) { - operationString = operationString.replaceAll("\\(..*\\)", "(...)"); - - final int lastPointPos = operationString.lastIndexOf('.', operationString.length() - 5); - operationString = operationString.substring(lastPointPos + 1); - } - item.setText(new String[] { executionEntry.getContainer(), componentName, operationString, Integer.toString(executionEntry.getCalls()) }); - - // if (executionEntry.isFailed()) { - // final Color colorRed = Display.getCurrent().getSystemColor(SWT.COLOR_RED); - // item.setForeground(colorRed); - // } - - item.setData(executionEntry); - item.setItemCount(0); - // item.setItemCount(executionEntry.getChildren().size()); - } - } - - private class ExecutionTracesTreeSetDataListener implements Listener { - - @Override - public void handleEvent(final Event event) { - // Get the necessary information from the event - final Tree tree = (Tree) event.widget; - final TreeItem item = (TreeItem) event.item; - final int tableIndex = event.index; - final TreeItem parent = item.getParentItem(); - - // Decide whether the current item is a root or not - final ExecutionEntry executionEntry; - final String traceID; - - if (parent == null) { - executionEntry = ((List<ExecutionEntry>) tree.getData()).get(tableIndex); - traceID = Long.toString(executionEntry.getTraceID()); - } else { - executionEntry = ((ExecutionEntry) parent.getData()).getChildren().get(tableIndex); - traceID = ""; - } - - String componentName = executionEntry.getComponent(); - if (Properties.getInstance().isShortComponentNames()) { - final int lastPointPos = componentName.lastIndexOf('.'); - componentName = componentName.substring(lastPointPos + 1); - } - String operationString = executionEntry.getOperation(); - if (Properties.getInstance().isShortOperationParameters()) { - operationString = operationString.replaceAll("\\(..*\\)", "(...)"); - - final int lastPointPos = operationString.lastIndexOf('.', operationString.length() - 5); - operationString = operationString.substring(lastPointPos + 1); - } - item.setText(new String[] { executionEntry.getContainer(), componentName, operationString, Long.toString(executionEntry.getDuration()), - String.format("%.1f%%", executionEntry.getPercent()), traceID }); - - if (executionEntry.isFailed()) { - final Color colorRed = Display.getCurrent().getSystemColor(SWT.COLOR_RED); - item.setForeground(colorRed); - } - - item.setData(executionEntry); - item.setItemCount(executionEntry.getChildren().size()); - } - } - - private class RecordsTableSetDataListener implements Listener { - - @Override - public void handleEvent(final Event event) { - // Get the necessary information from the event - final Table table = (Table) event.widget; - final TableItem item = (TableItem) event.item; - final int tableIndex = event.index; - - // Get the data for the current row - final List<RecordEntry> records = (List<RecordEntry>) table.getData(); - final RecordEntry record = records.get(tableIndex); - - // Get the data to display - final String timestampStr = Long.toString(record.getTimestamp()); - final String type = record.getType(); - final String recordStr = record.getRepresentation(); - item.setText(new String[] { timestampStr, type, recordStr }); - } - - } - - private class RecordsTableTimestampSortListener implements Listener { - - @Override - public void handleEvent(final Event 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 - int direction = table.getSortDirection(); - if (sortColumn == currentColumn) { - direction = ((direction == SWT.UP) ? SWT.DOWN : SWT.UP); - } else { - table.setSortColumn(currentColumn); - direction = SWT.UP; - } - - // Sort the data - final List<RecordEntry> records = (List<RecordEntry>) table.getData(); - Collections.sort(records, new RecordEntryTimestampComparator(direction)); - - // Update the data displayed in the table - table.setSortDirection(direction); - table.clearAll(); - } - } - - private class RecordsTableTypeSortListener implements Listener { - - @Override - public void handleEvent(final Event 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 - int direction = table.getSortDirection(); - if (sortColumn == currentColumn) { - direction = ((direction == SWT.UP) ? SWT.DOWN : SWT.UP); - } else { - table.setSortColumn(currentColumn); - direction = SWT.UP; - } - - // Sort the data - final List<IMonitoringRecord> records = (List<IMonitoringRecord>) table.getData(); - Collections.sort(records, new IMonitoringRecordTypeComparator(direction)); - - // Update the data displayed in the table - table.setSortDirection(direction); - table.clearAll(); - } - } - - private class RecordEntryTimestampComparator implements Comparator<RecordEntry> { - - private final int direction; - - public RecordEntryTimestampComparator(final int direction) { - this.direction = direction; - } - - @Override - public int compare(final RecordEntry o1, final RecordEntry o2) { - int result = Long.compare(o1.getTimestamp(), o2.getTimestamp()); - if (this.direction == SWT.UP) { - result = -result; - } - return result; - } - - } - - private class IMonitoringRecordTypeComparator implements Comparator<IMonitoringRecord> { - - private final int direction; - - public IMonitoringRecordTypeComparator(final int direction) { - this.direction = direction; - } - - @Override - public int compare(final IMonitoringRecord o1, final IMonitoringRecord o2) { - int result = o1.getClass().getCanonicalName().compareTo(o2.getClass().getCanonicalName()); - if (this.direction == SWT.UP) { - result = -result; - } - return result; - } - } - - private static class TreeUpdateObserver implements Observer { - - private final Tree tree; - - public TreeUpdateObserver(final Tree tree) { - this.tree = tree; - } - - @Override - public void update(final Observable observable, final Object obj) { - this.tree.clearAll(true); - } - - } - - private class ExecutionTraceTreeSelectionListener implements SelectionListener { - - @Override - public void widgetSelected(final SelectionEvent e) { - final Object data = e.item.getData(); - if (data instanceof ExecutionEntry) { - MainWindow.this.lblNa_1.setText(Long.toString(((ExecutionEntry) data).getTraceID())); - MainWindow.this.lblNa_3.setText(Long.toString(((ExecutionEntry) data).getDuration())); - - MainWindow.this.lblNa_4.setText(((ExecutionEntry) data).getContainer()); - MainWindow.this.lblNa_5.setText(((ExecutionEntry) data).getComponent()); - MainWindow.this.lblNa_6.setText(((ExecutionEntry) data).getOperation()); - MainWindow.this.lblNa_7.setText(Integer.toString(((ExecutionEntry) data).getStackDepth())); - - if (((ExecutionEntry) data).isFailed()) { - MainWindow.this.lblNa_2.setText("Yes (" + ((ExecutionEntry) data).getFailedCause() + ")"); - MainWindow.this.lblNa_2.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); - MainWindow.this.lblFailed.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); - } else { - MainWindow.this.lblNa_2.setText("No"); - MainWindow.this.lblNa_2.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); - MainWindow.this.lblFailed.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); - } - - MainWindow.this.lblNa_1.pack(); - MainWindow.this.lblNa_2.pack(); - MainWindow.this.lblNa_3.pack(); - MainWindow.this.lblNa_4.pack(); - MainWindow.this.lblNa_5.pack(); - MainWindow.this.lblNa_6.pack(); - MainWindow.this.lblNa_7.pack(); - } - } - - @Override - public void widgetDefaultSelected(final SelectionEvent e) { - - } - - } } diff --git a/src/main/java/kieker/gui/view/RecordEntryTimestampComparator.java b/src/main/java/kieker/gui/view/RecordEntryTimestampComparator.java new file mode 100644 index 00000000..45927152 --- /dev/null +++ b/src/main/java/kieker/gui/view/RecordEntryTimestampComparator.java @@ -0,0 +1,26 @@ +package kieker.gui.view; + +import java.util.Comparator; + +import kieker.gui.model.RecordEntry; + +import org.eclipse.swt.SWT; + +class RecordEntryTimestampComparator implements Comparator<RecordEntry> { + + private final int direction; + + public RecordEntryTimestampComparator(final int direction) { + this.direction = direction; + } + + @Override + public int compare(final RecordEntry o1, final RecordEntry o2) { + int result = Long.compare(o1.getTimestamp(), o2.getTimestamp()); + if (this.direction == SWT.UP) { + result = -result; + } + return result; + } + +} \ No newline at end of file diff --git a/src/main/java/kieker/gui/view/RecordEntryTypeComparator.java b/src/main/java/kieker/gui/view/RecordEntryTypeComparator.java new file mode 100644 index 00000000..28b80f21 --- /dev/null +++ b/src/main/java/kieker/gui/view/RecordEntryTypeComparator.java @@ -0,0 +1,25 @@ +package kieker.gui.view; + +import java.util.Comparator; + +import kieker.gui.model.RecordEntry; + +import org.eclipse.swt.SWT; + +class RecordEntryTypeComparator implements Comparator<RecordEntry> { + + private final int direction; + + public RecordEntryTypeComparator(final int direction) { + this.direction = direction; + } + + @Override + public int compare(final RecordEntry o1, final RecordEntry o2) { + int result = o1.getType().compareTo(o2.getType()); + if (this.direction == SWT.UP) { + result = -result; + } + return result; + } +} diff --git a/src/main/java/kieker/gui/view/RecordsTableSetDataListener.java b/src/main/java/kieker/gui/view/RecordsTableSetDataListener.java new file mode 100644 index 00000000..2bd108ba --- /dev/null +++ b/src/main/java/kieker/gui/view/RecordsTableSetDataListener.java @@ -0,0 +1,32 @@ +package kieker.gui.view; + +import java.util.List; + +import kieker.gui.model.RecordEntry; + +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableItem; + +class RecordsTableSetDataListener implements Listener { + + @Override + public void handleEvent(final Event event) { + // Get the necessary information from the event + final Table table = (Table) event.widget; + final TableItem item = (TableItem) event.item; + final int tableIndex = event.index; + + // Get the data for the current row + final List<RecordEntry> records = (List<RecordEntry>) table.getData(); + final RecordEntry record = records.get(tableIndex); + + // Get the data to display + final String timestampStr = Long.toString(record.getTimestamp()); + final String type = record.getType(); + final String recordStr = record.getRepresentation(); + item.setText(new String[] { timestampStr, type, recordStr }); + } + +} diff --git a/src/main/java/kieker/gui/view/RecordsTableTimestampSortListener.java b/src/main/java/kieker/gui/view/RecordsTableTimestampSortListener.java new file mode 100644 index 00000000..c5d9d414 --- /dev/null +++ b/src/main/java/kieker/gui/view/RecordsTableTimestampSortListener.java @@ -0,0 +1,40 @@ +package kieker.gui.view; + +import java.util.Collections; +import java.util.List; + +import kieker.gui.model.RecordEntry; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; + +class RecordsTableTimestampSortListener implements Listener { + + @Override + public void handleEvent(final Event 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 + int direction = table.getSortDirection(); + if (sortColumn == currentColumn) { + direction = ((direction == SWT.UP) ? SWT.DOWN : SWT.UP); + } else { + table.setSortColumn(currentColumn); + direction = SWT.UP; + } + + // Sort the data + final List<RecordEntry> records = (List<RecordEntry>) table.getData(); + Collections.sort(records, new RecordEntryTimestampComparator(direction)); + + // Update the data displayed in the table + table.setSortDirection(direction); + table.clearAll(); + } +} \ No newline at end of file diff --git a/src/main/java/kieker/gui/view/RecordsTableTypeSortListener.java b/src/main/java/kieker/gui/view/RecordsTableTypeSortListener.java new file mode 100644 index 00000000..5f0135cd --- /dev/null +++ b/src/main/java/kieker/gui/view/RecordsTableTypeSortListener.java @@ -0,0 +1,40 @@ +package kieker.gui.view; + +import java.util.Collections; +import java.util.List; + +import kieker.gui.model.RecordEntry; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; + +class RecordsTableTypeSortListener implements Listener { + + @Override + public void handleEvent(final Event 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 + int direction = table.getSortDirection(); + if (sortColumn == currentColumn) { + direction = ((direction == SWT.UP) ? SWT.DOWN : SWT.UP); + } else { + table.setSortColumn(currentColumn); + direction = SWT.UP; + } + + // Sort the data + final List<RecordEntry> records = (List<RecordEntry>) table.getData(); + Collections.sort(records, new RecordEntryTypeComparator(direction)); + + // Update the data displayed in the table + table.setSortDirection(direction); + table.clearAll(); + } +} diff --git a/src/main/java/kieker/gui/view/TreeUpdateObserver.java b/src/main/java/kieker/gui/view/TreeUpdateObserver.java new file mode 100644 index 00000000..1f308cb9 --- /dev/null +++ b/src/main/java/kieker/gui/view/TreeUpdateObserver.java @@ -0,0 +1,21 @@ +package kieker.gui.view; + +import java.util.Observable; +import java.util.Observer; + +import org.eclipse.swt.widgets.Tree; + +class TreeUpdateObserver implements Observer { + + private final Tree tree; + + public TreeUpdateObserver(final Tree tree) { + this.tree = tree; + } + + @Override + public void update(final Observable observable, final Object obj) { + this.tree.clearAll(true); + } + +} \ No newline at end of file -- GitLab