Skip to main content
summaryrefslogtreecommitdiffstats
blob: 57d62fba66001cc21083e521f3546496411c4aeb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.debug.internal.ui.actions.breakpointGroups;

import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointContainer;
import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsView;
import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsViewer;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Item;

/**
 * Removes a breakpoint from a breakpoint working set.
 */
public class RemoveFromWorkingSetAction extends BreakpointSelectionAction {
	
    /**
     * Constructs action to remove breakpoints from a category.
     * 
     * @param view
     */
    public RemoveFromWorkingSetAction(BreakpointsView view) {
        super(BreakpointGroupMessages.RemoveFromWorkingSetAction_0, view); 
    }
    
    /* (non-Javadoc)
     * @see org.eclipse.jface.action.IAction#run()
     */
    public void run() {
        BreakpointsViewer viewer = (BreakpointsViewer) getBreakpointsView().getViewer();
        Item[] items = viewer.getSelectedItems();
        IBreakpoint breakpoint = null;
        BreakpointContainer container = null;
        for(int i = 0; i < items.length; i++) {
        	if(items[i].getData() instanceof IBreakpoint) {
        		breakpoint = (IBreakpoint) items[i].getData();
        		container = viewer.getRemovableContainer(items[i]);
        		if(container != null) {
        			container.getOrganizer().removeBreakpoint(breakpoint, container.getCategory());
        		}
        	}
        }
    }
    
    /* (non-Javadoc)
     * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
     */
    protected boolean updateSelection(IStructuredSelection selection) {
        Object element = selection.getFirstElement();
        if(element instanceof BreakpointContainer) {
        	return ((BreakpointContainer) element).getCategory().equals(IDebugUIConstants.BREAKPOINT_WORKINGSET_ID);
        }
        return false;
    }
}

Back to the top