From 0e0894195948801404f2e65c9984697b41ddb276 Mon Sep 17 00:00:00 2001
From: Nils Christian Ehmke <nie@informatik.uni-kiel.de>
Date: Fri, 6 Feb 2015 14:58:59 +0100
Subject: [PATCH] Fixed some PMD, FB and CS issues

---
 config/findbugs/excludeFilter.xml             |  5 +
 .../kieker/diagnosis/mainview/Controller.java |  2 +-
 .../java/kieker/diagnosis/subview/Filter.java | 16 +++
 .../subview/aggregatedcalls/Controller.java   | 19 +++-
 .../subview/aggregatedcalls/View.java         | 98 ++++++++++++++++++-
 .../kieker/diagnosis/subview/calls/View.java  | 18 +++-
 .../calls/util/ComponentSortListener.java     | 16 +++
 .../calls/util/ContainerSortListener.java     | 16 +++
 .../calls/util/DurationSortListener.java      | 16 +++
 .../calls/util/OperationSortListener.java     | 16 +++
 .../calls/util/TraceIDSortListener.java       | 16 +++
 11 files changed, 232 insertions(+), 6 deletions(-)

diff --git a/config/findbugs/excludeFilter.xml b/config/findbugs/excludeFilter.xml
index 5eac8d5d..4a1eab8b 100644
--- a/config/findbugs/excludeFilter.xml
+++ b/config/findbugs/excludeFilter.xml
@@ -10,4 +10,9 @@
     <Bug pattern="SE_INNER_CLASS" />
 	</Match>
   
+  <Match>
+    <Class name="kieker.diagnosis.subview.util.AbstractCallTableColumnSortListener$CallComparator" />
+    <Bug pattern="SE_INNER_CLASS" />
+	</Match>
+  
 </FindBugsFilter>  
\ No newline at end of file
diff --git a/src/main/java/kieker/diagnosis/mainview/Controller.java b/src/main/java/kieker/diagnosis/mainview/Controller.java
index b7af4832..85077230 100644
--- a/src/main/java/kieker/diagnosis/mainview/Controller.java
+++ b/src/main/java/kieker/diagnosis/mainview/Controller.java
@@ -129,7 +129,7 @@ public final class Controller implements SelectionListener {
 		}
 	}
 
-	private void handlePotentialTreeSelection(final SelectionEvent e) {
+	private void handlePotentialTreeSelection(final SelectionEvent e) { // NOPMD (this method violates some metrics. This is acceptable, as it is readable)
 		if (e.item == this.mainView.getTrtmExplorer()) {
 			this.mainViewModel.setCurrentActiveSubView(SubView.NONE.name());
 		}
diff --git a/src/main/java/kieker/diagnosis/subview/Filter.java b/src/main/java/kieker/diagnosis/subview/Filter.java
index b3483be5..0393eeb0 100644
--- a/src/main/java/kieker/diagnosis/subview/Filter.java
+++ b/src/main/java/kieker/diagnosis/subview/Filter.java
@@ -1,3 +1,19 @@
+/***************************************************************************
+ * 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;
 
 public enum Filter {
diff --git a/src/main/java/kieker/diagnosis/subview/aggregatedcalls/Controller.java b/src/main/java/kieker/diagnosis/subview/aggregatedcalls/Controller.java
index bb434eb2..ae92716e 100644
--- a/src/main/java/kieker/diagnosis/subview/aggregatedcalls/Controller.java
+++ b/src/main/java/kieker/diagnosis/subview/aggregatedcalls/Controller.java
@@ -61,7 +61,24 @@ public final class Controller implements ISubController, SelectionListener {
 	}
 
 	private static IModel<OperationCall> createModelProxy(final DataModel dataModel, final Filter filter) {
-		return new OperationCallsModelProxy(dataModel);
+		if (filter == Filter.JUST_FAILED) {
+			return new FailedOperationCallsModelProxy(dataModel);
+		} else {
+			return new OperationCallsModelProxy(dataModel);
+		}
+	}
+
+	private static final class FailedOperationCallsModelProxy extends AbstractDataModelProxy<OperationCall> {
+
+		public FailedOperationCallsModelProxy(final DataModel dataModel) {
+			super(dataModel);
+		}
+
+		@Override
+		public List<OperationCall> getContent() {
+			return super.getDataModel().getFailedOperationCalls();
+		}
+
 	}
 
 	private static final class OperationCallsModelProxy extends AbstractDataModelProxy<OperationCall> {
diff --git a/src/main/java/kieker/diagnosis/subview/aggregatedcalls/View.java b/src/main/java/kieker/diagnosis/subview/aggregatedcalls/View.java
index bcb6dbd9..5edcddc5 100644
--- a/src/main/java/kieker/diagnosis/subview/aggregatedcalls/View.java
+++ b/src/main/java/kieker/diagnosis/subview/aggregatedcalls/View.java
@@ -1,8 +1,26 @@
+/***************************************************************************
+ * 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.aggregatedcalls;
 
+import java.util.List;
 import java.util.Observable;
 import java.util.Observer;
 
+import kieker.diagnosis.common.domain.AggregatedOperationCall;
 import kieker.diagnosis.common.domain.OperationCall;
 import kieker.diagnosis.common.model.PropertiesModel;
 import kieker.diagnosis.subview.ISubView;
@@ -13,12 +31,13 @@ import org.eclipse.swt.custom.SashForm;
 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.swt.widgets.Table;
 import org.eclipse.swt.widgets.TableColumn;
 import org.eclipse.wb.swt.SWTResourceManager;
 
-public class View implements ISubView, Observer {
+public final class View implements ISubView, Observer {
 
 	private static final String N_A = "N/A";
 	private Composite composite;
@@ -37,8 +56,17 @@ public class View implements ISubView, Observer {
 	private Composite statusBar;
 	private Label lblTraceEquivalence;
 	private Table table;
+	private final Model model;
+	private final IModel<OperationCall> modelProxy;
+	private final PropertiesModel propertiesModel;
+	private final Controller controller;
 
 	public View(final IModel<OperationCall> modelProxy, final Model model, final PropertiesModel propertiesModel, final Controller controller) {
+		this.model = model;
+		this.modelProxy = modelProxy;
+		this.propertiesModel = propertiesModel;
+		this.controller = controller;
+
 		modelProxy.addObserver(this);
 		model.addObserver(this);
 		propertiesModel.addObserver(this);
@@ -190,6 +218,8 @@ public class View implements ISubView, Observer {
 
 		this.lblTraceEquivalence = new Label(this.statusBar, SWT.NONE);
 		this.lblTraceEquivalence.setText("0 Aggregated Operation Calls");
+
+		this.table.addSelectionListener(this.controller);
 	}
 
 	@Override
@@ -198,9 +228,71 @@ public class View implements ISubView, Observer {
 	}
 
 	@Override
-	public void update(final Observable arg0, final Object arg1) {
-		// TODO Auto-generated method stub
+	public void update(final Observable observable, final Object obj) {
+		if (observable == this.modelProxy) {
+			this.updateTable();
+			this.updateStatusBar();
+		}
+		if (observable == this.model) {
+			this.updateDetailComposite();
+		}
+		if (observable == this.propertiesModel) {
+			this.clearTable();
+		}
+	}
+
+	private void updateStatusBar() {
+		this.lblTraceEquivalence.setText(this.modelProxy.getContent().size() + " Aggregated Operation Call(s)");
+		this.statusBar.getParent().layout();
+	}
+
+	private void updateTable() {
+		final List<OperationCall> calls = this.modelProxy.getContent();
+
+		this.table.setData(calls);
+		this.table.setItemCount(calls.size());
+		this.clearTable();
+	}
+
+	private void clearTable() {
+		this.table.clearAll();
+
+		for (final TableColumn column : this.table.getColumns()) {
+			column.pack();
+		}
+	}
+
+	private void updateDetailComposite() {
+		final AggregatedOperationCall call = this.model.getCurrentActiveCall();
+
+		final String minDuration = (call.getMinDuration() + " " + this.modelProxy.getShortTimeUnit()).trim();
+		final String maxDuration = (call.getMaxDuration() + " " + this.modelProxy.getShortTimeUnit()).trim();
+		final String meanDuration = (call.getMeanDuration() + " " + this.modelProxy.getShortTimeUnit()).trim();
+		final String avgDuration = (call.getAvgDuration() + " " + this.modelProxy.getShortTimeUnit()).trim();
+		final String totalDuration = (call.getTotalDuration() + " " + this.modelProxy.getShortTimeUnit()).trim();
+
+		this.lblMinimalDurationDisplay.setText(minDuration);
+		this.lblMaximalDurationDisplay.setText(maxDuration);
+		this.lblAverageDurationDisplay.setText(avgDuration);
+		this.lblMeanDurationDisplay.setText(meanDuration);
+		this.lblTotalDurationDisplay.setText(totalDuration);
+
+		this.lblExecutionContainerDisplay.setText(call.getContainer());
+		this.lblComponentDisplay.setText(call.getComponent());
+		this.lblOperationDisplay.setText(call.getOperation());
+		this.lblNumberOfCallsDisplay.setText(Integer.toString(call.getCalls()));
+
+		if (call.isFailed()) {
+			this.lblFailedDisplay.setText("Yes (" + call.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));
+		}
 
+		this.detailComposite.layout();
 	}
 
 }
diff --git a/src/main/java/kieker/diagnosis/subview/calls/View.java b/src/main/java/kieker/diagnosis/subview/calls/View.java
index 62a91f30..37aeb5a7 100644
--- a/src/main/java/kieker/diagnosis/subview/calls/View.java
+++ b/src/main/java/kieker/diagnosis/subview/calls/View.java
@@ -1,3 +1,19 @@
+/***************************************************************************
+ * 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.calls;
 
 import java.util.List;
@@ -32,7 +48,7 @@ import org.eclipse.swt.widgets.TableColumn;
 import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.wb.swt.SWTResourceManager;
 
-public class View implements ISubView, Observer {
+public final class View implements ISubView, Observer {
 
 	private static final String N_A = "N/A";
 	private Composite composite;
diff --git a/src/main/java/kieker/diagnosis/subview/calls/util/ComponentSortListener.java b/src/main/java/kieker/diagnosis/subview/calls/util/ComponentSortListener.java
index 3db3d6f9..13c86707 100644
--- a/src/main/java/kieker/diagnosis/subview/calls/util/ComponentSortListener.java
+++ b/src/main/java/kieker/diagnosis/subview/calls/util/ComponentSortListener.java
@@ -1,3 +1,19 @@
+/***************************************************************************
+ * 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.calls.util;
 
 import kieker.diagnosis.common.domain.OperationCall;
diff --git a/src/main/java/kieker/diagnosis/subview/calls/util/ContainerSortListener.java b/src/main/java/kieker/diagnosis/subview/calls/util/ContainerSortListener.java
index 56ed25a8..28204a84 100644
--- a/src/main/java/kieker/diagnosis/subview/calls/util/ContainerSortListener.java
+++ b/src/main/java/kieker/diagnosis/subview/calls/util/ContainerSortListener.java
@@ -1,3 +1,19 @@
+/***************************************************************************
+ * 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.calls.util;
 
 import kieker.diagnosis.common.domain.OperationCall;
diff --git a/src/main/java/kieker/diagnosis/subview/calls/util/DurationSortListener.java b/src/main/java/kieker/diagnosis/subview/calls/util/DurationSortListener.java
index d11ea753..3d8ea8ed 100644
--- a/src/main/java/kieker/diagnosis/subview/calls/util/DurationSortListener.java
+++ b/src/main/java/kieker/diagnosis/subview/calls/util/DurationSortListener.java
@@ -1,3 +1,19 @@
+/***************************************************************************
+ * 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.calls.util;
 
 import kieker.diagnosis.common.domain.OperationCall;
diff --git a/src/main/java/kieker/diagnosis/subview/calls/util/OperationSortListener.java b/src/main/java/kieker/diagnosis/subview/calls/util/OperationSortListener.java
index bc7a9da5..d9e1c037 100644
--- a/src/main/java/kieker/diagnosis/subview/calls/util/OperationSortListener.java
+++ b/src/main/java/kieker/diagnosis/subview/calls/util/OperationSortListener.java
@@ -1,3 +1,19 @@
+/***************************************************************************
+ * 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.calls.util;
 
 import kieker.diagnosis.common.domain.OperationCall;
diff --git a/src/main/java/kieker/diagnosis/subview/calls/util/TraceIDSortListener.java b/src/main/java/kieker/diagnosis/subview/calls/util/TraceIDSortListener.java
index 473e0b1c..aff55b23 100644
--- a/src/main/java/kieker/diagnosis/subview/calls/util/TraceIDSortListener.java
+++ b/src/main/java/kieker/diagnosis/subview/calls/util/TraceIDSortListener.java
@@ -1,3 +1,19 @@
+/***************************************************************************
+ * 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.calls.util;
 
 import kieker.diagnosis.common.domain.OperationCall;
-- 
GitLab