|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2015 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* IBM Corporation - initial API and implementation |
| 10 |
*******************************************************************************/ |
| 11 |
|
| 12 |
package org.eclipse.jdt.internal.debug.ui.sourcelookup; |
| 13 |
|
| 14 |
import org.eclipse.jdt.core.IJavaElement; |
| 15 |
import org.eclipse.jdt.core.IParent; |
| 16 |
import org.eclipse.jdt.core.JavaModelException; |
| 17 |
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; |
| 18 |
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider; |
| 19 |
import org.eclipse.jdt.ui.JavaElementLabels; |
| 20 |
import org.eclipse.jface.resource.ImageDescriptor; |
| 21 |
import org.eclipse.ui.model.IWorkbenchAdapter; |
| 22 |
|
| 23 |
/** |
| 24 |
* Class provides the JavaElement labels for WorkbenchAdapater Objects while debugging |
| 25 |
*/ |
| 26 |
public class JavaDebugWorkbenchAdapter implements IWorkbenchAdapter { |
| 27 |
private JavaElementImageProvider fImageProvider; |
| 28 |
|
| 29 |
public JavaDebugWorkbenchAdapter() { |
| 30 |
fImageProvider = new JavaElementImageProvider(); |
| 31 |
} |
| 32 |
|
| 33 |
/* |
| 34 |
* Append Root path to identify full path for duplicate Java elements in source lookup dialog |
| 35 |
*/ |
| 36 |
|
| 37 |
public String getLabel(Object element) { |
| 38 |
return JavaElementLabels.getTextLabel(getJavaElement(element), JavaElementLabels.ALL_DEFAULT | JavaElementLabels.APPEND_ROOT_PATH); |
| 39 |
} |
| 40 |
|
| 41 |
private IJavaElement getJavaElement(Object element) { |
| 42 |
if (element instanceof IJavaElement) { |
| 43 |
return (IJavaElement) element; |
| 44 |
} |
| 45 |
return null; |
| 46 |
} |
| 47 |
|
| 48 |
public Object[] getChildren(Object element) { |
| 49 |
IJavaElement je = getJavaElement(element); |
| 50 |
if (je instanceof IParent) { |
| 51 |
try { |
| 52 |
return ((IParent) je).getChildren(); |
| 53 |
} |
| 54 |
catch (JavaModelException e) { |
| 55 |
JDIDebugUIPlugin.log(e); |
| 56 |
} |
| 57 |
} |
| 58 |
return new Object[0]; |
| 59 |
} |
| 60 |
|
| 61 |
public ImageDescriptor getImageDescriptor(Object element) { |
| 62 |
IJavaElement je = getJavaElement(element); |
| 63 |
if (je != null) { |
| 64 |
return fImageProvider.getJavaImageDescriptor(je, JavaElementImageProvider.OVERLAY_ICONS | JavaElementImageProvider.SMALL_ICONS); |
| 65 |
} |
| 66 |
|
| 67 |
return null; |
| 68 |
|
| 69 |
} |
| 70 |
|
| 71 |
public Object getParent(Object element) { |
| 72 |
IJavaElement je = getJavaElement(element); |
| 73 |
return je != null ? je.getParent() : null; |
| 74 |
} |
| 75 |
} |