| /******************************************************************************* |
| * Copyright (c) 2019 Ericsson |
| * |
| * All rights reserved. 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 |
| *******************************************************************************/ |
| |
| package org.eclipse.tracecompass.internal.tmf.ui.views.handler; |
| |
| import org.eclipse.core.commands.AbstractHandler; |
| import org.eclipse.core.commands.ExecutionEvent; |
| import org.eclipse.core.commands.ExecutionException; |
| import org.eclipse.tracecompass.tmf.ui.views.TmfView; |
| import org.eclipse.ui.IWorkbenchPart; |
| import org.eclipse.ui.IWorkbenchWindow; |
| import org.eclipse.ui.PlatformUI; |
| import org.eclipse.ui.handlers.HandlerUtil; |
| |
| /** |
| * Base handler, makes sure we have a TMF view control selected. |
| * |
| * @author Matthew Khouzam |
| * |
| */ |
| abstract class TmfViewBaseHandler extends AbstractHandler { |
| |
| @Override |
| public Object execute(ExecutionEvent event) throws ExecutionException { |
| // Check if we are closing down |
| IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); |
| if (window != null) { |
| IWorkbenchPart part = HandlerUtil.getActivePart(event); |
| if (part instanceof TmfView) { |
| execute((TmfView) part); |
| } |
| } |
| return null; |
| } |
| |
| public abstract void execute(TmfView view); |
| } |