1 11 package org.eclipse.jdt.internal.debug.ui.actions; 12 13 14 import org.eclipse.jdt.debug.core.IJavaBreakpoint; 15 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; 16 import org.eclipse.jface.action.IAction; 17 import org.eclipse.jface.viewers.ISelection; 18 import org.eclipse.jface.viewers.ISelectionChangedListener; 19 import org.eclipse.jface.viewers.ISelectionProvider; 20 import org.eclipse.jface.viewers.IStructuredSelection; 21 import org.eclipse.jface.viewers.StructuredSelection; 22 import org.eclipse.jface.window.IShellProvider; 23 import org.eclipse.swt.widgets.Shell; 24 import org.eclipse.ui.IObjectActionDelegate; 25 import org.eclipse.ui.IWorkbenchPart; 26 import org.eclipse.ui.dialogs.PropertyDialogAction; 27 28 32 public class JavaBreakpointPropertiesAction implements IObjectActionDelegate { 33 34 private IWorkbenchPart fPart; 35 private IJavaBreakpoint fBreakpoint; 36 37 40 public void run(IAction action) { 41 if(fBreakpoint != null) { 42 IShellProvider provider; 43 if (fPart != null) { 44 provider = fPart.getSite(); 45 } else { 46 provider = new IShellProvider() { 47 public Shell getShell() { 48 return JDIDebugUIPlugin.getActiveWorkbenchShell(); 49 } 50 }; 51 } 52 PropertyDialogAction propertyAction= 53 new PropertyDialogAction(provider, new ISelectionProvider() { 54 public void addSelectionChangedListener(ISelectionChangedListener listener) { 55 } 56 public ISelection getSelection() { 57 return new StructuredSelection(fBreakpoint); 58 } 59 public void removeSelectionChangedListener(ISelectionChangedListener listener) { 60 } 61 public void setSelection(ISelection selection) { 62 } 63 }); 64 propertyAction.run(); 65 } 66 } 67 68 71 public void selectionChanged(IAction action, ISelection selection) { 72 if (selection instanceof IStructuredSelection) { 73 IStructuredSelection ss= (IStructuredSelection)selection; 74 if (ss.isEmpty() || ss.size() > 1) { 75 return; 76 } 77 Object element= ss.getFirstElement(); 78 if (element instanceof IJavaBreakpoint) { 79 setBreakpoint((IJavaBreakpoint)element); 80 } 81 else { 82 setBreakpoint(null); 83 } 84 } 85 } 86 87 91 public void setBreakpoint(IJavaBreakpoint breakpoint) { 92 fBreakpoint = breakpoint; 93 } 94 95 98 public void setActivePart(IAction action, IWorkbenchPart targetPart) { 99 fPart = targetPart; 100 } 101 } 102 | Popular Tags |