From 96e7a246932f08d17b1e6de1d38559fd33b37719 Mon Sep 17 00:00:00 2001
From: Nils Christian Ehmke <nie@informatik.uni-kiel.de>
Date: Mon, 8 Dec 2014 15:02:00 +0100
Subject: [PATCH] Added some more code for the trace aggregation

---
 .../gui/model/AggregatedExecutionEntry.java   | 29 ++++++++++++++++---
 .../java/kieker/gui/model/Properties.java     |  4 +--
 .../importer/filter/TraceAggregator.java      |  2 +-
 ...tedExecutionTracesTreeSetDataListener.java | 25 +++++++++-------
 src/main/java/kieker/gui/view/MainWindow.java |  3 +-
 5 files changed, 45 insertions(+), 18 deletions(-)

diff --git a/src/main/java/kieker/gui/model/AggregatedExecutionEntry.java b/src/main/java/kieker/gui/model/AggregatedExecutionEntry.java
index f366ffad..efc6ef1a 100644
--- a/src/main/java/kieker/gui/model/AggregatedExecutionEntry.java
+++ b/src/main/java/kieker/gui/model/AggregatedExecutionEntry.java
@@ -1,16 +1,30 @@
 package kieker.gui.model;
 
+import java.util.ArrayList;
+import java.util.List;
+
 public final class AggregatedExecutionEntry {
 
+	private final List<AggregatedExecutionEntry> children = new ArrayList<>();
+	private final String failedCause;
 	private final String container;
 	private final String component;
 	private final String operation;
 	private int calls;
 
-	public AggregatedExecutionEntry(final String container, final String component, final String operation) {
-		this.container = container;
-		this.component = component;
-		this.operation = operation;
+	public AggregatedExecutionEntry(final ExecutionEntry execEntry) {
+		this.container = execEntry.getContainer();
+		this.component = execEntry.getComponent();
+		this.operation = execEntry.getOperation();
+		this.failedCause = execEntry.getFailedCause();
+
+		for (final ExecutionEntry child : execEntry.getChildren()) {
+			this.children.add(new AggregatedExecutionEntry(child));
+		}
+	}
+
+	public List<AggregatedExecutionEntry> getChildren() {
+		return this.children;
 	}
 
 	public String getContainer() {
@@ -33,4 +47,11 @@ public final class AggregatedExecutionEntry {
 		return this.calls;
 	}
 
+	public String getFailedCause() {
+		return this.failedCause;
+	}
+
+	public boolean isFailed() {
+		return (this.failedCause != null);
+	}
 }
diff --git a/src/main/java/kieker/gui/model/Properties.java b/src/main/java/kieker/gui/model/Properties.java
index 6661c236..b52fb21c 100644
--- a/src/main/java/kieker/gui/model/Properties.java
+++ b/src/main/java/kieker/gui/model/Properties.java
@@ -20,14 +20,14 @@ import java.util.Observable;
 
 /**
  * An observable singleton container for properties used within this application.
- * 
+ *
  * @author Nils Christian Ehmke
  */
 public final class Properties extends Observable {
 
 	private static final Properties INSTANCE = new Properties();
 	private boolean shortComponentNames = false;
-	private boolean shortOperationParameters = false;
+	private boolean shortOperationParameters = true;
 
 	private Properties() {}
 
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 22f72ea5..d852bab3 100644
--- a/src/main/java/kieker/gui/model/importer/filter/TraceAggregator.java
+++ b/src/main/java/kieker/gui/model/importer/filter/TraceAggregator.java
@@ -35,7 +35,7 @@ public final class TraceAggregator extends AbstractConsumerStage<ExecutionEntry>
 	@Override
 	protected void execute(final ExecutionEntry execEntry) {
 		if (!this.aggregationMap.containsKey(execEntry)) {
-			final AggregatedExecutionEntry aggregatedExecutionEntry = new AggregatedExecutionEntry(execEntry.getContainer(), execEntry.getComponent(), execEntry.getOperation());
+			final AggregatedExecutionEntry aggregatedExecutionEntry = new AggregatedExecutionEntry(execEntry);
 			this.aggregationMap.put(execEntry, aggregatedExecutionEntry);
 		}
 		this.aggregationMap.get(execEntry).incrementCalls();
diff --git a/src/main/java/kieker/gui/view/AggregatedExecutionTracesTreeSetDataListener.java b/src/main/java/kieker/gui/view/AggregatedExecutionTracesTreeSetDataListener.java
index b6d1bb6b..e1a354cb 100644
--- a/src/main/java/kieker/gui/view/AggregatedExecutionTracesTreeSetDataListener.java
+++ b/src/main/java/kieker/gui/view/AggregatedExecutionTracesTreeSetDataListener.java
@@ -5,6 +5,9 @@ import java.util.List;
 import kieker.gui.model.AggregatedExecutionEntry;
 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;
@@ -25,8 +28,7 @@ class AggregatedExecutionTracesTreeSetDataListener implements Listener {
 		if (parent == null) {
 			executionEntry = ((List<AggregatedExecutionEntry>) tree.getData()).get(tableIndex);
 		} else {
-			// executionEntry = ((AggregatedExecutionEntry) parent.getData()).getChildren().get(tableIndex);
-			executionEntry = null;
+			executionEntry = ((AggregatedExecutionEntry) parent.getData()).getChildren().get(tableIndex);
 		}
 
 		String componentName = executionEntry.getComponent();
@@ -41,15 +43,18 @@ class AggregatedExecutionTracesTreeSetDataListener implements Listener {
 			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 (parent != null) {
+			item.setText(new String[] { executionEntry.getContainer(), componentName, operationString, "" });
+		} else {
+			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);
-		// }
+		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());
+		item.setItemCount(executionEntry.getChildren().size());
 	}
-}
\ 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 22c3be9d..46be0975 100644
--- a/src/main/java/kieker/gui/view/MainWindow.java
+++ b/src/main/java/kieker/gui/view/MainWindow.java
@@ -301,6 +301,7 @@ public class MainWindow {
 		this.tree_1 = new Tree(this.sashForm, SWT.BORDER | SWT.FULL_SELECTION | SWT.VIRTUAL);
 		this.tree_1.setHeaderVisible(true);
 		this.tree_1.addListener(SWT.SetData, new AggregatedExecutionTracesTreeSetDataListener());
+		Properties.getInstance().addObserver(new TreeUpdateObserver(this.tree_1));
 
 		this.treeColumn = new TreeColumn(this.tree_1, SWT.NONE);
 		this.treeColumn.setWidth(100);
@@ -396,6 +397,7 @@ public class MainWindow {
 		this.mntmView_1.setMenu(this.menu);
 
 		this.mntmShortOperationParameters = new MenuItem(this.menu, SWT.RADIO);
+		this.mntmShortOperationParameters.setSelection(true);
 		this.mntmShortOperationParameters.addSelectionListener(new SelectionAdapter() {
 			@Override
 			public void widgetSelected(final SelectionEvent e) {
@@ -411,7 +413,6 @@ public class MainWindow {
 				Properties.getInstance().setShortOperationParameters(false);
 			}
 		});
-		this.mntmLongOperationParameters.setSelection(true);
 		this.mntmLongOperationParameters.setText("Long Operation Parameters");
 
 		new MenuItem(this.menu, SWT.SEPARATOR);
-- 
GitLab