KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > actions > breakpoints > 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.breakpoints;
12
13 import org.eclipse.core.resources.IMarkerDelta;
14 import org.eclipse.debug.core.DebugPlugin;
15 import org.eclipse.debug.core.IBreakpointsListener;
16 import org.eclipse.debug.core.model.IBreakpoint;
17 import org.eclipse.debug.internal.ui.actions.SelectAllAction;
18 import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsView;
19 import org.eclipse.debug.ui.IDebugView;
20 import org.eclipse.jface.action.IAction;
21 import org.eclipse.jface.viewers.CheckboxTreeViewer;
22
23 public class SelectAllBreakpointsAction extends SelectAllAction implements IBreakpointsListener {
24
25     /* (non-Javadoc)
26      * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#isEnabled()
27      */

28     protected boolean isEnabled() {
29         return DebugPlugin.getDefault().getBreakpointManager().hasBreakpoints();
30     }
31
32     public void run(IAction action) {
33         if (!(getView() instanceof BreakpointsView)) {
34             return;
35         }
36         CheckboxTreeViewer viewer = ((BreakpointsView) getView()).getCheckboxViewer();
37         viewer.getTree().selectAll();
38         // ensure that the selection change callback is fired
39
viewer.setSelection(viewer.getSelection());
40     }
41     
42     /* (non-Javadoc)
43      * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsAdded(org.eclipse.debug.core.model.IBreakpoint[])
44      */

45     public void breakpointsAdded(IBreakpoint[] breakpoints) {
46         if (getAction() != null && !getAction().isEnabled()) {
47             update();
48         }
49     }
50
51     /* (non-Javadoc)
52      * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsChanged(org.eclipse.debug.core.model.IBreakpoint[], org.eclipse.core.resources.IMarkerDelta[])
53      */

54     public void breakpointsChanged(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) {
55     }
56
57     /* (non-Javadoc)
58      * @see org.eclipse.debug.core.IBreakpointsListener#breakpointsRemoved(org.eclipse.debug.core.model.IBreakpoint[], org.eclipse.core.resources.IMarkerDelta[])
59      */

60     public void breakpointsRemoved(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) {
61         if (getAction() != null) {
62             update();
63         }
64     }
65
66     /* (non-Javadoc)
67      * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#initialize()
68      */

69     protected void initialize() {
70         DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);
71     }
72
73     /* (non-Javadoc)
74      * @see org.eclipse.debug.internal.ui.actions.selection.AbstractRemoveAllActionDelegate#dispose()
75      */

76     public void dispose() {
77         DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this);
78         super.dispose();
79     }
80
81     /* (non-Javadoc)
82      * @see org.eclipse.debug.internal.ui.actions.selection.SelectAllAction#getActionId()
83      */

84     protected String JavaDoc getActionId() {
85         return IDebugView.SELECT_ALL_ACTION;
86     }
87 }
88
Popular Tags