KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > actions > breakpointGroups > RemoveFromWorkingSetAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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.breakpointGroups;
12
13 import org.eclipse.debug.core.model.IBreakpoint;
14 import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointContainer;
15 import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsView;
16 import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsViewer;
17 import org.eclipse.debug.ui.IDebugUIConstants;
18 import org.eclipse.jface.viewers.IStructuredSelection;
19 import org.eclipse.swt.widgets.Item;
20
21 /**
22  * Removes a breakpoint from a breakpoint working set.
23  */

24 public class RemoveFromWorkingSetAction extends BreakpointSelectionAction {
25     
26     /**
27      * Constructs action to remove breakpoints from a category.
28      *
29      * @param view
30      */

31     public RemoveFromWorkingSetAction(BreakpointsView view) {
32         super(BreakpointGroupMessages.RemoveFromWorkingSetAction_0, view);
33     }
34     
35     /* (non-Javadoc)
36      * @see org.eclipse.jface.action.IAction#run()
37      */

38     public void run() {
39         BreakpointsViewer viewer = (BreakpointsViewer) getBreakpointsView().getViewer();
40         Item[] items = viewer.getSelectedItems();
41         IBreakpoint breakpoint = null;
42         BreakpointContainer container = null;
43         for(int i = 0; i < items.length; i++) {
44             if(items[i].getData() instanceof IBreakpoint) {
45                 breakpoint = (IBreakpoint) items[i].getData();
46                 container = viewer.getRemovableContainer(items[i]);
47                 if(container != null) {
48                     container.getOrganizer().removeBreakpoint(breakpoint, container.getCategory());
49                 }
50             }
51         }
52     }
53     
54     /* (non-Javadoc)
55      * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
56      */

57     protected boolean updateSelection(IStructuredSelection selection) {
58         Object JavaDoc element = selection.getFirstElement();
59         if(element instanceof BreakpointContainer) {
60             return ((BreakpointContainer) element).getCategory().equals(IDebugUIConstants.BREAKPOINT_WORKINGSET_ID);
61         }
62         return false;
63     }
64 }
65
Popular Tags