1) Action for breakpoint properties menu.
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.ui / src / net / sourceforge / phpdt / internal / debug / ui / actions / PHPDebugBreakpointAction.java
1 package net.sourceforge.phpdt.internal.debug.ui.actions;
2
3 import org.eclipse.jface.action.IAction;
4 import org.eclipse.jface.viewers.ISelection;
5 import org.eclipse.jface.viewers.IStructuredSelection;
6 import org.eclipse.ui.IViewActionDelegate;
7 import org.eclipse.ui.IViewPart;
8
9 import net.sourceforge.phpdt.internal.debug.ui.properties.*;
10 import net.sourceforge.phpdt.internal.debug.core.breakpoints.*;
11
12 /**
13  * Enables the context menu entry if object is of type PHPLineBreakpoint.
14  * This is used for Breakpoint properties menu.
15  * Properties menu let you set 'skip count' and condition of a PHP breakpoint. 
16  * 
17  */
18
19 public class PHPDebugBreakpointAction implements IViewActionDelegate {
20         protected PHPLineBreakpoint fBreakpoint = null;
21         
22         public void init(IViewPart view) {
23
24         }
25
26         public void run(IAction action) {
27                 PHPBreakpointPropertiesDialog dialog = new PHPBreakpointPropertiesDialog (null, fBreakpoint);
28                 dialog.open();  
29         }
30
31         public void selectionChanged(IAction action, ISelection selection) {
32                 IStructuredSelection bpSelection;
33                 Object               bpObject;
34                 
35                 if (selection instanceof IStructuredSelection) {
36                         bpSelection = (IStructuredSelection) selection;
37                         
38                         if (bpSelection.size () == 1) {                                         // Do we have something selected
39                                 bpObject = bpSelection.getFirstElement();               // Get the selected object
40                                 
41                                 if (bpObject instanceof PHPLineBreakpoint) {    // Is the object of type PHPLineBreakpoint?
42                                         fBreakpoint = (PHPLineBreakpoint) bpObject;
43                                         action.setEnabled (true);                                       // Then enable the context menu item
44                                         return;
45                                 }
46                         }
47                 }       
48                 
49                 action.setEnabled (false);                                                              // It isn't a PHPLineBreakpoint, so disable the menu item 
50         }
51 }