A massive organize imports and formatting of the sources using default Eclipse code...
[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 net.sourceforge.phpdt.internal.debug.core.breakpoints.PHPLineBreakpoint;
4 import net.sourceforge.phpdt.internal.debug.ui.properties.PHPBreakpointPropertiesDialog;
5
6 import org.eclipse.jface.action.IAction;
7 import org.eclipse.jface.viewers.ISelection;
8 import org.eclipse.jface.viewers.IStructuredSelection;
9 import org.eclipse.ui.IViewActionDelegate;
10 import org.eclipse.ui.IViewPart;
11
12 /**
13  * Enables the context menu entry if object is of type PHPLineBreakpoint. This
14  * is used for Breakpoint properties menu. Properties menu let you set 'skip
15  * 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(
28                                 null, fBreakpoint);
29                 dialog.open();
30         }
31
32         public void selectionChanged(IAction action, ISelection selection) {
33                 IStructuredSelection bpSelection;
34                 Object bpObject;
35
36                 if (selection instanceof IStructuredSelection) {
37                         bpSelection = (IStructuredSelection) selection;
38
39                         if (bpSelection.size() == 1) { // Do we have something selected
40                                 bpObject = bpSelection.getFirstElement(); // Get the selected
41                                                                                                                         // object
42
43                                 if (bpObject instanceof PHPLineBreakpoint) { // Is the object
44                                                                                                                                 // of type
45                                                                                                                                 // PHPLineBreakpoint?
46                                         fBreakpoint = (PHPLineBreakpoint) bpObject;
47                                         action.setEnabled(true); // Then enable the context menu
48                                                                                                 // item
49                                         return;
50                                 }
51                         }
52                 }
53
54                 action.setEnabled(false); // It isn't a PHPLineBreakpoint, so disable
55                                                                         // the menu item
56         }
57 }