From 59aa51d5afc3e038cd2d2794d786ec35d80f0955 Mon Sep 17 00:00:00 2001 From: Nils Christian Ehmke <nie@informatik.uni-kiel.de> Date: Mon, 8 Dec 2014 17:28:19 +0100 Subject: [PATCH] Moved some parts of the view into composites. --- .../view/AggregatedTraceDetailComposite.java | 97 ++++++++++ src/main/java/kieker/gui/view/MainWindow.java | 176 ++---------------- .../kieker/gui/view/TraceDetailComposite.java | 120 ++++++++++++ 3 files changed, 234 insertions(+), 159 deletions(-) create mode 100644 src/main/java/kieker/gui/view/AggregatedTraceDetailComposite.java create mode 100644 src/main/java/kieker/gui/view/TraceDetailComposite.java diff --git a/src/main/java/kieker/gui/view/AggregatedTraceDetailComposite.java b/src/main/java/kieker/gui/view/AggregatedTraceDetailComposite.java new file mode 100644 index 00000000..546cf001 --- /dev/null +++ b/src/main/java/kieker/gui/view/AggregatedTraceDetailComposite.java @@ -0,0 +1,97 @@ +package kieker.gui.view; + +import kieker.gui.model.domain.AggregatedExecutionEntry; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.wb.swt.SWTResourceManager; + +public final class AggregatedTraceDetailComposite extends Composite { + + private final Label lblExecutionContainerDisplay; + private final Label lblComponentDisplay; + private final Label lblOperationDisplay; + private final Label lblFailed; + private final Label lblFailedDisplay; + + private final Label lblCalledDisplay; + + public AggregatedTraceDetailComposite(final Composite parent, final int style) { + super(parent, style); + this.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.setLayout(new GridLayout(2, false)); + + final Label lblExecutionContainer = new Label(this, SWT.NONE); + lblExecutionContainer.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblExecutionContainer.setText("Execution Container:"); + + this.lblExecutionContainerDisplay = new Label(this, SWT.NONE); + this.lblExecutionContainerDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblExecutionContainerDisplay.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); + this.lblExecutionContainerDisplay.setText("N/A"); + + final Label lblComponent = new Label(this, SWT.NONE); + lblComponent.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblComponent.setText("Component:"); + + this.lblComponentDisplay = new Label(this, SWT.NONE); + this.lblComponentDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblComponentDisplay.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); + this.lblComponentDisplay.setText("N/A"); + + final Label lblOperation = new Label(this, SWT.NONE); + lblOperation.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblOperation.setText("Operation:"); + + this.lblOperationDisplay = new Label(this, SWT.NONE); + this.lblOperationDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblOperationDisplay.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); + this.lblOperationDisplay.setText("N/A"); + + this.lblFailed = new Label(this, SWT.NONE); + this.lblFailed.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblFailed.setText("Failed:"); + + this.lblFailedDisplay = new Label(this, SWT.NONE); + this.lblFailedDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblFailedDisplay.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); + this.lblFailedDisplay.setText("N/A"); + + final Label lblCalled = new Label(this, SWT.NONE); + lblCalled.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblCalled.setText("# Calls:"); + + this.lblCalledDisplay = new Label(this, SWT.NONE); + this.lblCalledDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblCalledDisplay.setText("N/A"); + } + + public void setTraceToDisplay(final AggregatedExecutionEntry trace) { + this.lblExecutionContainerDisplay.setText(trace.getContainer()); + this.lblComponentDisplay.setText(trace.getComponent()); + this.lblOperationDisplay.setText(trace.getOperation()); + this.lblCalledDisplay.setText(Integer.toString(trace.getCalls())); + + if (trace.isFailed()) { + this.lblFailedDisplay.setText("Yes (" + trace.getFailedCause() + ")"); + this.lblFailedDisplay.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); + this.lblFailed.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); + } else { + this.lblFailedDisplay.setText("No"); + this.lblFailedDisplay.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); + this.lblFailed.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); + } + + super.layout(); + } + + @Override + protected void checkSubclass() { + // Disable the check that prevents subclassing of SWT components + } + +} diff --git a/src/main/java/kieker/gui/view/MainWindow.java b/src/main/java/kieker/gui/view/MainWindow.java index c21dd4f7..87206fca 100644 --- a/src/main/java/kieker/gui/view/MainWindow.java +++ b/src/main/java/kieker/gui/view/MainWindow.java @@ -101,38 +101,14 @@ public final class MainWindow { private TreeColumn trclmnPercent; Label lblNa; private SashForm executionTracesForm; - private Composite executionTracesDetailComposite; - private Label lblTraceId; - Label lblNa_1; - Label lblFailed; - Label lblNa_2; - private Label lblDuration; - Label lblNa_3; - private Label lblExecutionContainer; - private Label lblComponent; - private Label lblOperation; - Label lblNa_4; - Label lblNa_5; - Label lblNa_6; - private Label lblStackDepth; - Label lblNa_7; + private TraceDetailComposite traceDetailComposite; private SashForm sashForm; private Tree aggregatedTracesTree; private TreeColumn treeColumn; private TreeColumn treeColumn_1; private TreeColumn treeColumn_2; private TreeColumn trclmnCalls; - private Composite composite; - private Label label; - private Label label_1; - private Label label_2; - private Label label_3; - private Label label_4; - private Label label_5; - private Label label_10; - private Label label_11; - private Label label_12; - private Label label_13; + private AggregatedTraceDetailComposite aggregatedTraceDetailComposite; TreeItem trtmAggregatedExecutionTraces; public static void main(final String[] args) { @@ -235,66 +211,7 @@ public final class MainWindow { this.treeColumn_16.setWidth(100); this.treeColumn_16.setText("Trace ID"); - this.executionTracesDetailComposite = new Composite(this.executionTracesForm, SWT.BORDER); - this.executionTracesDetailComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - this.executionTracesDetailComposite.setLayout(new GridLayout(2, false)); - - this.lblExecutionContainer = new Label(this.executionTracesDetailComposite, SWT.NONE); - this.lblExecutionContainer.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - this.lblExecutionContainer.setText("Execution Container:"); - - this.lblNa_4 = new Label(this.executionTracesDetailComposite, SWT.NONE); - this.lblNa_4.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); - this.lblNa_4.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - this.lblNa_4.setText("N/A"); - - this.lblComponent = new Label(this.executionTracesDetailComposite, SWT.NONE); - this.lblComponent.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - this.lblComponent.setText("Component:"); - - this.lblNa_5 = new Label(this.executionTracesDetailComposite, SWT.NONE); - this.lblNa_5.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - this.lblNa_5.setText("N/A"); - - this.lblOperation = new Label(this.executionTracesDetailComposite, SWT.NONE); - this.lblOperation.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - this.lblOperation.setText("Operation:"); - - this.lblNa_6 = new Label(this.executionTracesDetailComposite, SWT.NONE); - this.lblNa_6.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - this.lblNa_6.setText("N/A"); - - this.lblTraceId = new Label(this.executionTracesDetailComposite, SWT.NONE); - this.lblTraceId.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - this.lblTraceId.setText("Trace ID:"); - - this.lblNa_1 = new Label(this.executionTracesDetailComposite, SWT.NONE); - this.lblNa_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - this.lblNa_1.setText("N/A"); - - this.lblDuration = new Label(this.executionTracesDetailComposite, SWT.NONE); - this.lblDuration.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - this.lblDuration.setText("Duration:"); - - this.lblNa_3 = new Label(this.executionTracesDetailComposite, SWT.NONE); - this.lblNa_3.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - this.lblNa_3.setText("N/A"); - - this.lblStackDepth = new Label(this.executionTracesDetailComposite, SWT.NONE); - this.lblStackDepth.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - this.lblStackDepth.setText("Stack Depth:"); - - this.lblNa_7 = new Label(this.executionTracesDetailComposite, SWT.NONE); - this.lblNa_7.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - this.lblNa_7.setText("N/A"); - - this.lblFailed = new Label(this.executionTracesDetailComposite, SWT.NONE); - this.lblFailed.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - this.lblFailed.setText("Failed:"); - - this.lblNa_2 = new Label(this.executionTracesDetailComposite, SWT.NONE); - this.lblNa_2.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - this.lblNa_2.setText("N/A"); + this.traceDetailComposite = new TraceDetailComposite(this.executionTracesForm, SWT.BORDER); this.executionTracesForm.setWeights(new int[] { 2, 1 }); this.sashForm = new SashForm(this.mainComposite, SWT.VERTICAL); @@ -318,50 +235,7 @@ public final class MainWindow { this.trclmnCalls.setWidth(100); this.trclmnCalls.setText("# Calls"); - this.composite = new Composite(this.sashForm, SWT.BORDER); - this.composite.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - this.composite.setLayout(new GridLayout(2, false)); - - this.label = new Label(this.composite, SWT.NONE); - this.label.setText("Execution Container:"); - this.label.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - - this.label_1 = new Label(this.composite, SWT.NONE); - this.label_1.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); - this.label_1.setText("N/A"); - this.label_1.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - - this.label_2 = new Label(this.composite, SWT.NONE); - this.label_2.setText("Component:"); - this.label_2.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - - this.label_3 = new Label(this.composite, SWT.NONE); - this.label_3.setText("N/A"); - this.label_3.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - - this.label_4 = new Label(this.composite, SWT.NONE); - this.label_4.setText("Operation:"); - this.label_4.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - - this.label_5 = new Label(this.composite, SWT.NONE); - this.label_5.setText("N/A"); - this.label_5.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - - this.label_10 = new Label(this.composite, SWT.NONE); - this.label_10.setText("Stack Depth:"); - this.label_10.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - - this.label_11 = new Label(this.composite, SWT.NONE); - this.label_11.setText("N/A"); - this.label_11.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - - this.label_12 = new Label(this.composite, SWT.NONE); - this.label_12.setText("Failed:"); - this.label_12.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); - - this.label_13 = new Label(this.composite, SWT.NONE); - this.label_13.setText("N/A"); - this.label_13.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.aggregatedTraceDetailComposite = new AggregatedTraceDetailComposite(this.sashForm, SWT.BORDER); this.sashForm.setWeights(new int[] { 2, 1 }); this.outerForm.setWeights(new int[] { 2, 4 }); @@ -506,7 +380,19 @@ public final class MainWindow { public void widgetSelected(final SelectionEvent e) { final Object data = e.item.getData(); if (data instanceof ExecutionEntry) { - MainWindow.this.handleTracesSelection((ExecutionEntry) data); + MainWindow.this.traceDetailComposite.setTraceToDisplay((ExecutionEntry) data); + } + } + + }); + + this.aggregatedTracesTree.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(final SelectionEvent e) { + final Object data = e.item.getData(); + if (data instanceof AggregatedExecutionEntry) { + MainWindow.this.aggregatedTraceDetailComposite.setTraceToDisplay((AggregatedExecutionEntry) data); } } @@ -556,34 +442,6 @@ public final class MainWindow { } } - private void handleTracesSelection(final ExecutionEntry data) { - this.lblNa_1.setText(Long.toString(data.getTraceID())); - this.lblNa_3.setText(Long.toString(data.getDuration())); - - this.lblNa_4.setText(data.getContainer()); - this.lblNa_5.setText(data.getComponent()); - this.lblNa_6.setText(data.getOperation()); - this.lblNa_7.setText(Integer.toString(data.getStackDepth())); - - if (data.isFailed()) { - this.lblNa_2.setText("Yes (" + data.getFailedCause() + ")"); - this.lblNa_2.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); - this.lblFailed.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); - } else { - this.lblNa_2.setText("No"); - this.lblNa_2.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); - this.lblFailed.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); - } - - this.lblNa_1.pack(); - this.lblNa_2.pack(); - this.lblNa_3.pack(); - this.lblNa_4.pack(); - this.lblNa_5.pack(); - this.lblNa_6.pack(); - this.lblNa_7.pack(); - } - private void reloadFromModel() { // Reload the data from the model... final List<RecordEntry> records = DataSource.getInstance().getRecords(); diff --git a/src/main/java/kieker/gui/view/TraceDetailComposite.java b/src/main/java/kieker/gui/view/TraceDetailComposite.java new file mode 100644 index 00000000..33dc54e4 --- /dev/null +++ b/src/main/java/kieker/gui/view/TraceDetailComposite.java @@ -0,0 +1,120 @@ +package kieker.gui.view; + +import kieker.gui.model.domain.ExecutionEntry; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.wb.swt.SWTResourceManager; + +public final class TraceDetailComposite extends Composite { + + private final Label lblExecutionContainerDisplay; + private final Label lblComponentDisplay; + private final Label lblOperationDisplay; + private final Label lblTraceIdDisplay; + private final Label lblDurationDisplay; + private final Label lblStackDepthDisplay; + private final Label lblFailed; + private final Label lblFailedDisplay; + + public TraceDetailComposite(final Composite parent, final int style) { + super(parent, style); + this.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.setLayout(new GridLayout(2, false)); + + final Label lblExecutionContainer = new Label(this, SWT.NONE); + lblExecutionContainer.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblExecutionContainer.setText("Execution Container:"); + + this.lblExecutionContainerDisplay = new Label(this, SWT.NONE); + this.lblExecutionContainerDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblExecutionContainerDisplay.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); + this.lblExecutionContainerDisplay.setText("N/A"); + + final Label lblComponent = new Label(this, SWT.NONE); + lblComponent.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblComponent.setText("Component:"); + + this.lblComponentDisplay = new Label(this, SWT.NONE); + this.lblComponentDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblComponentDisplay.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); + this.lblComponentDisplay.setText("N/A"); + + final Label lblOperation = new Label(this, SWT.NONE); + lblOperation.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblOperation.setText("Operation:"); + + this.lblOperationDisplay = new Label(this, SWT.NONE); + this.lblOperationDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblOperationDisplay.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); + this.lblOperationDisplay.setText("N/A"); + + final Label lblTraceId = new Label(this, SWT.NONE); + lblTraceId.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblTraceId.setText("Trace ID:"); + + this.lblTraceIdDisplay = new Label(this, SWT.NONE); + this.lblTraceIdDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblTraceIdDisplay.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); + this.lblTraceIdDisplay.setText("N/A"); + + final Label lblDuration = new Label(this, SWT.NONE); + lblDuration.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblDuration.setText("Duration:"); + + this.lblDurationDisplay = new Label(this, SWT.NONE); + this.lblDurationDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblDurationDisplay.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); + this.lblDurationDisplay.setText("N/A"); + + final Label lblStackDepth = new Label(this, SWT.NONE); + lblStackDepth.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + lblStackDepth.setText("Stack Depth:"); + + this.lblStackDepthDisplay = new Label(this, SWT.NONE); + this.lblStackDepthDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblStackDepthDisplay.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); + this.lblStackDepthDisplay.setText("N/A"); + + this.lblFailed = new Label(this, SWT.NONE); + this.lblFailed.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblFailed.setText("Failed:"); + + this.lblFailedDisplay = new Label(this, SWT.NONE); + this.lblFailedDisplay.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE)); + this.lblFailedDisplay.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); + this.lblFailedDisplay.setText("N/A"); + } + + public void setTraceToDisplay(final ExecutionEntry trace) { + this.lblTraceIdDisplay.setText(Long.toString(trace.getTraceID())); + this.lblDurationDisplay.setText(Long.toString(trace.getDuration())); + + this.lblExecutionContainerDisplay.setText(trace.getContainer()); + this.lblComponentDisplay.setText(trace.getComponent()); + this.lblOperationDisplay.setText(trace.getOperation()); + this.lblStackDepthDisplay.setText(Integer.toString(trace.getStackDepth())); + + if (trace.isFailed()) { + this.lblFailedDisplay.setText("Yes (" + trace.getFailedCause() + ")"); + this.lblFailedDisplay.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); + this.lblFailed.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); + } else { + this.lblFailedDisplay.setText("No"); + this.lblFailedDisplay.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); + this.lblFailed.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); + } + + super.layout(); + } + + @Override + protected void checkSubclass() { + // Disable the check that prevents subclassing of SWT components + } + +} -- GitLab