Bug 522378: Resolved potential problems detected by Sonar

Change-Id: I7c5e8134aede936629c85acae8d8993925976dd3
Signed-off-by: Karsten Thoms <karsten.thoms@itemis.de>
diff --git a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/typeconstraints/FullConstraintCreator.java b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/typeconstraints/FullConstraintCreator.java
index 332d972..d77fa58 100644
--- a/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/typeconstraints/FullConstraintCreator.java
+++ b/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/typeconstraints/FullConstraintCreator.java
@@ -363,7 +363,7 @@
 			List<ITypeConstraint> all= new ArrayList<>();
 			all.addAll(Arrays.asList(defines));
 			all.addAll(Arrays.asList(constraints));
-			return (ITypeConstraint[])all.toArray();
+			return all.toArray(new ITypeConstraint[all.size()]);
 		}
 	}
 
diff --git a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/history/RefactoringHistoryControl.java b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/history/RefactoringHistoryControl.java
index 63f5bfa..eb7b657 100644
--- a/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/history/RefactoringHistoryControl.java
+++ b/org.eclipse.ltk.ui.refactoring/src/org/eclipse/ltk/internal/ui/refactoring/history/RefactoringHistoryControl.java
@@ -735,22 +735,19 @@
 			if (proxies.length > 0)
 				enable= true;
 		}
-		if (fDetailField != null)
+		if (fDetailField != null) {
 			fDetailField.setEnabled(enable);
-		if (fDetailLabel != null)
+			fDetailField.setText(enable ? fControlConfiguration.getCommentCaption() : ""); //$NON-NLS-1$
+		}
+		if (fDetailLabel != null) {
 			fDetailLabel.setEnabled(enable);
-		if (fHistoryPane != null)
+		}
+		if (fHistoryPane != null) {
 			fHistoryPane.setEnabled(enable);
-		if (fSelectionLabel != null)
+		}
+		if (fSelectionLabel != null) {
 			fSelectionLabel.setEnabled(enable);
-		if (enable) {
-			fDetailField.setText(fControlConfiguration.getCommentCaption());
-			if (fSelectionLabel != null)
-				fSelectionLabel.setText(RefactoringUIMessages.RefactoringHistoryControl_no_selection);
-		} else {
-			fDetailField.setText(""); //$NON-NLS-1$
-			if (fSelectionLabel != null)
-				fSelectionLabel.setText(""); //$NON-NLS-1$
+			fSelectionLabel.setText(enable ? RefactoringUIMessages.RefactoringHistoryControl_no_selection : "");  //$NON-NLS-1$
 		}
 	}