1 11 package org.eclipse.jdt.internal.debug.ui.variables; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.debug.core.DebugException; 15 import org.eclipse.debug.core.model.IValue; 16 import org.eclipse.debug.core.model.IVariable; 17 import org.eclipse.debug.internal.ui.elements.adapters.VariableLabelAdapter; 18 import org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext; 19 import org.eclipse.jdt.debug.core.IJavaValue; 20 import org.eclipse.jdt.internal.debug.core.model.JDIObjectValue; 21 import org.eclipse.jdt.internal.debug.ui.DebugUIMessages; 22 import org.eclipse.jdt.internal.debug.ui.IJDIPreferencesConstants; 23 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; 24 import org.eclipse.jdt.internal.debug.ui.JDIModelPresentation; 25 import org.eclipse.ui.IWorkbenchPart; 26 27 31 public class JavaVariableLabelAdapter extends VariableLabelAdapter { 32 33 public static JDIModelPresentation fLabelProvider = new JDIModelPresentation(); 34 35 38 protected String getValueText(IVariable variable, IValue value, IPresentationContext context) throws CoreException { 39 if (value instanceof IJavaValue) { 40 return escapeSpecialChars(fLabelProvider.getFormattedValueText((IJavaValue) value)); 41 } 42 return super.getValueText(variable, value, context); 43 } 44 45 48 protected String getValueTypeName(IVariable variable, IValue value, IPresentationContext context) throws CoreException { 49 String typeName= DebugUIMessages.JDIModelPresentation_unknown_type__2; 50 try { 51 typeName = value.getReferenceTypeName(); 52 if (!isShowQualfiiedNames(context)) { 53 return fLabelProvider.removeQualifierFromGenericName(typeName); 54 } 55 } catch (DebugException e) {} 56 return typeName; 57 } 58 59 62 protected String getVariableTypeName(IVariable variable, IPresentationContext context) throws CoreException { 63 String typeName= DebugUIMessages.JDIModelPresentation_unknown_type__2; 64 try { 65 typeName = variable.getReferenceTypeName(); 66 if (!isShowQualfiiedNames(context)) { 67 return fLabelProvider.removeQualifierFromGenericName(typeName); 68 } 69 } catch (DebugException e) {} 70 return typeName; 71 } 72 73 private boolean isShowQualfiiedNames(IPresentationContext context) { 74 IWorkbenchPart part = context.getPart(); 75 if (part != null) { 76 return JDIDebugUIPlugin.getDefault().getPluginPreferences().getBoolean(part.getSite().getId() + "." + IJDIPreferencesConstants.PREF_SHOW_QUALIFIED_NAMES); } 78 return false; 79 } 80 81 84 protected String getColumnText(IVariable variable, IValue value, String columnId, IPresentationContext context) throws CoreException { 85 if (JavaVariableColumnPresentation.COLUMN_INSTANCE_ID.equals(columnId)) { 86 if (value instanceof JDIObjectValue) { 87 long uniqueId = ((JDIObjectValue)value).getUniqueId(); 88 StringBuffer buffer = new StringBuffer (); 89 buffer.append(uniqueId); 90 return buffer.toString(); 91 } else { 92 return ""; } 94 } 95 return super.getColumnText(variable, value, columnId, context); 96 } 97 98 99 100 } 101 | Popular Tags |