Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e3c9047331a521186b3d4366b25116a648849a55 (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
/*******************************************************************************
 * Copyright (c) 2006, 2007 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.debug.internal.ui.actions.breakpoints;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchPart;


/**
 * Global retargettable toggle breakpoint action.
 *
 * @since 3.3
 */
public class RetargetToggleBreakpointAction extends RetargetBreakpointAction {

	/* (non-Javadoc)
	 * @see org.eclipse.debug.internal.ui.actions.RetargetBreakpointAction#performAction(java.lang.Object, org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart)
	 */
	@Override
	protected void performAction(Object target, ISelection selection, IWorkbenchPart part) throws CoreException {
		if (target instanceof IToggleBreakpointsTargetExtension) {
			IToggleBreakpointsTargetExtension ext = (IToggleBreakpointsTargetExtension) target;
			ext.toggleBreakpoints(part, selection);
		} else {
			((IToggleBreakpointsTarget)target).toggleLineBreakpoints(part, selection);
		}
	}
	/* (non-Javadoc)
	 * @see org.eclipse.debug.internal.ui.actions.RetargetBreakpointAction#canPerformAction(java.lang.Object, org.eclipse.jface.viewers.ISelection, org.eclipse.ui.IWorkbenchPart)
	 */
	@Override
	protected boolean canPerformAction(Object target, ISelection selection, IWorkbenchPart part) {
		if (target instanceof IToggleBreakpointsTargetExtension) {
			IToggleBreakpointsTargetExtension ext = (IToggleBreakpointsTargetExtension) target;
			return ext.canToggleBreakpoints(part, selection);
		} else {
			return ((IToggleBreakpointsTarget)target).canToggleLineBreakpoints(part, selection);
		}
	}
	/* (non-Javadoc)
	 * @see org.eclipse.debug.internal.ui.actions.RetargetAction#getOperationUnavailableMessage()
	 */
	@Override
	protected String getOperationUnavailableMessage() {
		return Messages.RetargetToggleBreakpointAction_0;
	}
}

Back to the top