1 /******************************************************************************* 2 * Copyright (c) 2000, 2015 IBM Corporation and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 * 11 * Contributors: 12 * IBM Corporation - initial API and implementation 13 *******************************************************************************/ 14 package org.eclipse.jdt.internal.debug.ui.actions; 15 16 17 import org.eclipse.jdt.debug.core.IJavaBreakpoint; 18 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; 19 import org.eclipse.jface.action.IAction; 20 import org.eclipse.jface.dialogs.ErrorDialog; 21 import org.eclipse.jface.viewers.ISelection; 22 import org.eclipse.jface.viewers.IStructuredSelection; 23 import org.eclipse.ui.IActionDelegate; 24 import org.eclipse.ui.IObjectActionDelegate; 25 import org.eclipse.ui.IWorkbenchPart; 26 import org.eclipse.ui.dialogs.PreferencesUtil; 27 28 /** 29 * Presents the standard properties dialog to configure 30 * the attributes of a Java Breakpoint. 31 */ 32 public class JavaBreakpointPropertiesAction implements IObjectActionDelegate { 33 34 private IJavaBreakpoint fBreakpoint; 35 36 /** 37 * @see IActionDelegate#run(IAction) 38 */ 39 @Override run(IAction action)40 public void run(IAction action) { 41 //hack to prevent https://bugs.eclipse.org/bugs/show_bug.cgi?id=269878 42 //where conditions randomly seem to have errors while using an IBM VM in testing mode 43 if(fBreakpoint != null && !ErrorDialog.AUTOMATED_MODE) { 44 PreferencesUtil.createPropertyDialogOn( 45 JDIDebugUIPlugin.getActiveWorkbenchShell(), 46 fBreakpoint, 47 null, 48 null, 49 null).open(); 50 } 51 } 52 53 /** 54 * @see IActionDelegate#selectionChanged(IAction, ISelection) 55 */ 56 @Override selectionChanged(IAction action, ISelection selection)57 public void selectionChanged(IAction action, ISelection selection) { 58 if (selection instanceof IStructuredSelection) { 59 IStructuredSelection ss= (IStructuredSelection)selection; 60 if (ss.isEmpty() || ss.size() > 1) { 61 return; 62 } 63 Object element= ss.getFirstElement(); 64 if (element instanceof IJavaBreakpoint) { 65 setBreakpoint((IJavaBreakpoint)element); 66 } 67 else { 68 setBreakpoint(null); 69 } 70 } 71 } 72 73 /** 74 * Allows the underlying breakpoint for the properties page to be set 75 * @param breakpoint 76 */ setBreakpoint(IJavaBreakpoint breakpoint)77 public void setBreakpoint(IJavaBreakpoint breakpoint) { 78 fBreakpoint = breakpoint; 79 } 80 81 /** 82 * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart) 83 */ 84 @Override setActivePart(IAction action, IWorkbenchPart targetPart)85 public void setActivePart(IAction action, IWorkbenchPart targetPart) {} 86 } 87