1 /*******************************************************************************2 * Copyright (c) 2000, 2007 IBM Corporation and others.3 * All rights reserved. This program and the accompanying materials4 * are made available under the terms of the Eclipse Public License v1.05 * which accompanies this distribution, and is available at6 * http://www.eclipse.org/legal/epl-v10.html7 * 8 * Contributors:9 * IBM Corporation - initial API and implementation10 *******************************************************************************/11 package org.eclipse.jdt.internal.debug.ui.actions;12 13 14 import org.eclipse.debug.core.DebugException;15 import org.eclipse.jdt.debug.core.IJavaType;16 import org.eclipse.jdt.debug.core.IJavaValue;17 import org.eclipse.jdt.debug.core.IJavaVariable;18 import org.eclipse.jdt.internal.debug.ui.DetailFormatter;19 import org.eclipse.jdt.internal.debug.ui.JavaDetailFormattersManager;20 import org.eclipse.jdt.internal.debug.ui.display.JavaInspectExpression;21 import org.eclipse.jface.action.IAction;22 import org.eclipse.jface.viewers.IStructuredSelection;23 24 public class RemoveDetailFormatterAction extends ObjectActionDelegate {25 26 /**27 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)28 */29 public void run(IAction action) {30 IStructuredSelection selection= getCurrentSelection();31 if (selection == null || selection.size() != 1) {32 return;33 }34 Object element= selection.getFirstElement();35 IJavaType type;36 try {37 IJavaValue value;38 if (element instanceof IJavaVariable) {39 value = ((IJavaValue)((IJavaVariable) element).getValue());40 } else if (element instanceof JavaInspectExpression) {41 value = ((IJavaValue)((JavaInspectExpression) element).getValue());42 } else {43 return;44 }45 type= value.getJavaType();46 } catch (DebugException e) {47 return;48 }49 JavaDetailFormattersManager detailFormattersManager= JavaDetailFormattersManager.getDefault();50 DetailFormatter detailFormatter= detailFormattersManager.getAssociatedDetailFormatter(type);51 detailFormattersManager.removeAssociatedDetailFormatter(detailFormatter);52 }53 54 }55