Bug 56062 - [source lookup] Duplicate source lookup should indicate full
location of duplicate

Change-Id: I5c8a54ddfe99396fb7f86509b2c4c538b6efe804
diff --git a/org.eclipse.jdt.debug.ui/plugin.xml b/org.eclipse.jdt.debug.ui/plugin.xml
index 8e0b12a..f755402 100644
--- a/org.eclipse.jdt.debug.ui/plugin.xml
+++ b/org.eclipse.jdt.debug.ui/plugin.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?eclipse version="3.0"?>
 <!--
-     Copyright (c) 2005, 2014 IBM Corporation and others.
+     Copyright (c) 2005, 2015 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
@@ -3216,6 +3216,11 @@
             adaptableType="org.eclipse.jdt.launching.sourcelookup.containers.ClasspathContainerSourceContainer">
             <adapter type="org.eclipse.ui.model.IWorkbenchAdapter"/>
          </factory>   
+  		<factory 
+            class="org.eclipse.jdt.internal.debug.ui.sourcelookup.SourceElementLabelProviderAdapterFactory" 
+            adaptableType="org.eclipse.jdt.core.IJavaElement">
+            <adapter type="org.eclipse.debug.internal.ui.sourcelookup.SourceElementLabelProvider"/>
+  		</factory>
     
     <!-- Adapters for runtime classpath entries -->
          <factory 
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/sourcelookup/SourceElementLabelProviderAdapter.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/sourcelookup/SourceElementLabelProviderAdapter.java
new file mode 100644
index 0000000..1f44485
--- /dev/null
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/sourcelookup/SourceElementLabelProviderAdapter.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jdt.internal.debug.ui.sourcelookup;
+
+import org.eclipse.debug.internal.ui.sourcelookup.SourceElementLabelProvider;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.ui.JavaElementLabelProvider;
+import org.eclipse.jdt.ui.JavaElementLabels;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Class provides the Duplicate JavaElement labels and Images for SourceElementLabelProvider Objects while debugging
+ * 
+ * @since 3.7
+ */
+@SuppressWarnings("restriction")
+public class SourceElementLabelProviderAdapter extends SourceElementLabelProvider {
+
+	// Append Root path to identify full path for duplicate Java elements in source lookup dialog
+	@Override
+	public String getText(Object element) {
+		return JavaElementLabels.getTextLabel(getJavaElement(element), JavaElementLabels.ALL_DEFAULT | JavaElementLabels.APPEND_ROOT_PATH);
+	}
+
+	private IJavaElement getJavaElement(Object element) {
+		if (element instanceof IJavaElement) {
+			return (IJavaElement) element;
+		}
+		return null;
+	}
+
+	@Override
+	public Image getImage(Object element) {
+		return new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT).getImage(element);
+	}
+
+}
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/sourcelookup/SourceElementLabelProviderAdapterFactory.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/sourcelookup/SourceElementLabelProviderAdapterFactory.java
new file mode 100644
index 0000000..03a14c1
--- /dev/null
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/sourcelookup/SourceElementLabelProviderAdapterFactory.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.debug.ui.sourcelookup;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.jdt.core.IJavaElement;
+
+/**
+ * Adapter factory for duplicate source lookup elements.
+ * 
+ * @since 3.7
+ */
+public class SourceElementLabelProviderAdapterFactory implements IAdapterFactory {
+	/* (non-Javadoc)
+	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
+	 */
+	@Override
+	@SuppressWarnings({ "unchecked", "restriction" })
+	public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
+		if (adapterType.equals(org.eclipse.debug.internal.ui.sourcelookup.SourceElementLabelProvider.class)
+				&& adaptableObject instanceof IJavaElement) {
+			return (T) new SourceElementLabelProviderAdapter();
+		}
+		return null;
+	}
+	/* (non-Javadoc)
+	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+	 */
+	@SuppressWarnings("restriction")
+	@Override
+	public Class<?>[] getAdapterList() {
+		return new Class[] { org.eclipse.debug.internal.ui.sourcelookup.SourceElementLabelProvider.class };
+	}
+}