|
| 1 | +/******************************************************************************* |
| 2 | + * Copyright (c) 2025 IBM Corporation and others. |
| 3 | + * |
| 4 | + * This program and the accompanying materials |
| 5 | + * are made available under the terms of the Eclipse Public License 2.0 |
| 6 | + * which accompanies this distribution, and is available at |
| 7 | + * https://www.eclipse.org/legal/epl-2.0/ |
| 8 | + * |
| 9 | + * SPDX-License-Identifier: EPL-2.0 |
| 10 | + * |
| 11 | + * Contributors: |
| 12 | + * IBM Corporation - initial API and implementation |
| 13 | + *******************************************************************************/ |
| 14 | +package org.eclipse.debug.internal.ui.views.breakpoints; |
| 15 | + |
| 16 | +import org.eclipse.core.commands.AbstractHandler; |
| 17 | +import org.eclipse.core.commands.ExecutionEvent; |
| 18 | +import org.eclipse.core.commands.ExecutionException; |
| 19 | +import org.eclipse.debug.core.model.IBreakpoint; |
| 20 | +import org.eclipse.debug.internal.ui.actions.breakpoints.BreakpointLabelAction; |
| 21 | +import org.eclipse.debug.ui.IDebugUIConstants; |
| 22 | +import org.eclipse.jface.viewers.ISelection; |
| 23 | +import org.eclipse.jface.viewers.IStructuredSelection; |
| 24 | +import org.eclipse.ui.IViewPart; |
| 25 | +import org.eclipse.ui.IWorkbenchPage; |
| 26 | +import org.eclipse.ui.PlatformUI; |
| 27 | +import org.eclipse.ui.handlers.HandlerUtil; |
| 28 | + |
| 29 | +/** |
| 30 | + * Default handler for Custom Breakpoint Label action |
| 31 | + * |
| 32 | + */ |
| 33 | +public class BreakpointLabelCommandHandler extends AbstractHandler { |
| 34 | + |
| 35 | + /* |
| 36 | + * (non-Javadoc) |
| 37 | + * |
| 38 | + * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
| 39 | + */ |
| 40 | + @Override |
| 41 | + public Object execute(ExecutionEvent event) throws ExecutionException { |
| 42 | + |
| 43 | + ISelection rawSelection = HandlerUtil.getCurrentSelection(event); |
| 44 | + if (!(rawSelection instanceof IStructuredSelection selection)) { |
| 45 | + return null; |
| 46 | + } |
| 47 | + |
| 48 | + Object element = selection.getFirstElement(); |
| 49 | + if (!(element instanceof IBreakpoint)) { |
| 50 | + return null; |
| 51 | + } |
| 52 | + |
| 53 | + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); |
| 54 | + IViewPart view = page.findView(IDebugUIConstants.ID_BREAKPOINT_VIEW); |
| 55 | + if (view != null) { |
| 56 | + BreakpointLabelAction action = new BreakpointLabelAction(); |
| 57 | + action.init(view); |
| 58 | + action.run(null); |
| 59 | + } |
| 60 | + return null; |
| 61 | + } |
| 62 | +} |
0 commit comments