1 11 package org.eclipse.jdt.internal.debug.ui.actions; 12 13 import org.eclipse.debug.core.DebugException; 14 import org.eclipse.debug.core.model.IVariable; 15 import org.eclipse.debug.internal.ui.DebugUIPlugin; 16 import org.eclipse.debug.ui.actions.IVariableValueEditor; 17 import org.eclipse.jdt.debug.core.IJavaVariable; 18 import org.eclipse.jdt.internal.debug.ui.JDIModelPresentation; 19 import org.eclipse.swt.widgets.Shell; 20 21 24 public class JavaVariableValueEditor implements IVariableValueEditor { 25 26 29 public boolean editVariable(IVariable variable, Shell shell) { 30 String signature= null; 31 try { 32 signature= getSignature(variable); 33 } catch (DebugException e) { 34 DebugUIPlugin.errorDialog(shell, ActionMessages.JavaVariableValueEditor_0, ActionMessages.JavaVariableValueEditor_1, e); } 36 if (signature == null) { 37 return false; 38 } 39 IVariableValueEditor editor; 40 if (JDIModelPresentation.isObjectValue(signature)) { 41 editor= new JavaObjectValueEditor(); 42 } else { 43 editor= new JavaPrimitiveValueEditor(signature); 45 } 46 return editor.editVariable(variable, shell); 47 } 48 49 52 public boolean saveVariable(IVariable variable, String expression, Shell shell) { 53 try { 54 if (JDIModelPresentation.isObjectValue(getSignature(variable))) { 55 IVariableValueEditor editor= new JavaObjectValueEditor(); 56 return editor.saveVariable(variable, expression, shell); 57 } 58 } catch (DebugException e) { 59 DebugUIPlugin.errorDialog(shell, ActionMessages.JavaVariableValueEditor_0, ActionMessages.JavaVariableValueEditor_1, e); } 61 return false; 62 } 63 64 public static String getSignature(IVariable variable) throws DebugException { 65 String signature= null; 66 IJavaVariable javaVariable = (IJavaVariable) variable.getAdapter(IJavaVariable.class); 67 if (javaVariable != null) { 68 signature = javaVariable.getSignature(); 69 } 70 return signature; 71 } 72 73 } 74 | Popular Tags |