Bug 439744 - CompareToBaselineWizard fails in Eclipse 4.4

Change-Id: I9c3663c180cc694e91e5f23328689f0591e919a9
diff --git a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/actions/ActionMessages.java b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/actions/ActionMessages.java
index 109b6df..5a1f9ea 100644
--- a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/actions/ActionMessages.java
+++ b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/actions/ActionMessages.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * Copyright (c) 2008, 2014 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -27,6 +27,7 @@
 	public static String CompareDialogComputeDeltasTaskName;
 	public static String CompareWithAction_compared_project_with;
 	public static String CompareWithAction_compared_with_against;
+	public static String CompareWithAction_compared_against_nothing;
 	public static String CompareWithAction_comparing_apis;
 	public static String CompareTaskNoChanges;
 	public static String CompareToBaselineWizardPage_compare_with_baseline;
diff --git a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/actions/actionmessages.properties b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/actions/actionmessages.properties
index 78c0492..240c77c 100644
--- a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/actions/actionmessages.properties
+++ b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/actions/actionmessages.properties
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2008, 2011 IBM Corporation and others.
+# Copyright (c) 2008, 2014 IBM Corporation and others.
 # All rights reserved. This program and the accompanying materials
 # are made available under the terms of the Eclipse Public License v1.0
 # which accompanies this distribution, and is available at
@@ -17,7 +17,8 @@
 CompareDialogCollectingElementTaskName=Collecting elements to compare
 CompareDialogComputeDeltasTaskName=Computing deltas...
 CompareWithAction_compared_project_with=Compared {0} against ''{1}'' - {2} API changes found.
-CompareWithAction_compared_with_against=Compared {0} project(s) against ''{1}'' - {2} API changes found.
+CompareWithAction_compared_with_against=Compared {0} items against ''{1}'' - {2} API changes found.
+CompareWithAction_compared_against_nothing=Nothing selected to compare against.
 CompareWithAction_comparing_apis=Comparing APIs...
 CompareTaskNoChanges=No changes have been found
 CompareToBaselineWizardPage_compare_with_baseline=Compare with baseline
diff --git a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/wizards/CompareOperation.java b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/wizards/CompareOperation.java
index eac7590..6f42bea 100644
--- a/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/wizards/CompareOperation.java
+++ b/apitools/org.eclipse.pde.api.tools.ui/src/org/eclipse/pde/api/tools/ui/internal/wizards/CompareOperation.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2013 IBM Corporation and others.
+ * Copyright (c) 2009, 2014 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -92,9 +92,13 @@
 				String description = NLS.bind(ActionMessages.CompareWithAction_compared_with_against, new Object[] {
 						new Integer(size), baselineName,
 						new Integer(delta.getChildren().length) });
-				if (size == 1) {
+				if (size == 0) {
+					description = ActionMessages.CompareWithAction_compared_against_nothing;
+				} else if (size == 1) {
+					Object selectedElement = this.selection.getFirstElement();
+					String elementName = selectedElement instanceof IJavaElement ? ((IJavaElement) selectedElement).getElementName() : selectedElement.toString();
 					description = NLS.bind(ActionMessages.CompareWithAction_compared_project_with, new Object[] {
-							((IJavaElement) this.selection.getFirstElement()).getElementName(),
+							elementName,
 							baselineName,
 							new Integer(delta.getChildren().length) });
 				}