KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > actions > SelectAllBreakpointsAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui.actions;
12
13
14 import org.eclipse.core.resources.IMarkerDelta;
15 import org.eclipse.debug.core.DebugPlugin;
16 import org.eclipse.debug.core.IBreakpointsListener;
17 import org.eclipse.debug.core.model.IBreakpoint;
18 import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsView;
19 import org.eclipse.debug.ui.IDebugView;
20 import org.eclipse.jface.viewers.CheckboxTreeViewer;
21 import org.eclipse.ui.IViewPart;
22
23 public class SelectAllBreakpointsAction extends SelectAllAction implements IBreakpointsListener {
24
25     protected void update() {
26         getAction().setEnabled(
27             DebugPlugin.getDefault().getBreakpointManager().hasBreakpoints());
28     }
29
30     /**
31      * @see AbstractDebugActionDelegate#doAction(Object)
32      */

33     protected void doAction(Object JavaDoc element) {
34         if (!(getView() instanceof BreakpointsView)) {
35             return;
36         }
37         CheckboxTreeViewer viewer = ((BreakpointsView) getView()).getCheckboxViewer();
38         viewer.getTree().selectAll();
39         //ensure that the selection change callback is fired
40
viewer.setSelection(viewer.getSelection());
41     }
42
43     /**
44      * @see IBreakpointsListener#breakpointsAdded(IBreakpoint[])breakpointAdded(IBreakpoint)
45      */

46     public void breakpointsAdded(IBreakpoint[] breakpoints) {
47         if (getAction() != null && !getAction().isEnabled()) {
48             update();
49         }
50     }
51
52     /**
53      * @see IBreakpointsListener#breakpointsChanged(IBreakpoint[], IMarkerDelta[])breakpointChanged(IBreakpoint, IMarkerDelta)
54      */

55     public void breakpointsChanged(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) {
56     }
57
58     /**
59      * @see IBreakpointsListener#breakpointsRemoved(IBreakpoint[], IMarkerDelta[])
60      */

61     public void breakpointsRemoved(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) {
62         if (getAction() != null) {
63             update();
64         }
65     }
66     
67     /**
68      * @see IViewActionDelegate#init(IViewPart)
69      */

70     public void init(IViewPart view) {
71         super.init(view);
72         DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);
73     }
74     
75     public void dispose() {
76         DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this);
77         super.dispose();
78     }
79     
80     protected String JavaDoc getActionId() {
81         return IDebugView.SELECT_ALL_ACTION;
82     }
83 }
84
Popular Tags