Commit | Line | Data |
---|---|---|
be222f56 | 1 | /******************************************************************************* |
c8422608 | 2 | * Copyright (c) 2010, 2013 Ericsson |
a0a88f65 | 3 | * |
be222f56 PT |
4 | * All rights reserved. This program and the accompanying materials are |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
a0a88f65 | 8 | * |
be222f56 PT |
9 | * Contributors: |
10 | * Patrick Tasse - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.internal.tmf.ui.editors.handlers; | |
14 | ||
15 | import org.eclipse.core.commands.AbstractHandler; | |
16 | import org.eclipse.core.commands.ExecutionEvent; | |
17 | import org.eclipse.core.commands.ExecutionException; | |
18 | import org.eclipse.linuxtools.tmf.ui.editors.TmfEventsEditor; | |
19 | import org.eclipse.ui.IEditorPart; | |
20 | import org.eclipse.ui.IWorkbench; | |
21 | import org.eclipse.ui.IWorkbenchPage; | |
22 | import org.eclipse.ui.PlatformUI; | |
23 | ||
a0a88f65 AM |
24 | /** |
25 | * Handler to add bookmarks. | |
26 | * | |
27 | * @author Patrick Tasse | |
28 | */ | |
be222f56 PT |
29 | public class AddBookmarkHandler extends AbstractHandler { |
30 | ||
a0a88f65 | 31 | @Override |
be222f56 | 32 | public boolean isEnabled() { |
a0a88f65 | 33 | return true; |
be222f56 PT |
34 | } |
35 | ||
a0a88f65 AM |
36 | @Override |
37 | public Object execute(ExecutionEvent event) throws ExecutionException { | |
be222f56 PT |
38 | IWorkbench wb = PlatformUI.getWorkbench(); |
39 | IWorkbenchPage activePage = wb.getActiveWorkbenchWindow().getActivePage(); | |
40 | IEditorPart activeEditor = activePage.getActiveEditor(); | |
41 | if (activeEditor instanceof TmfEventsEditor) { | |
a0a88f65 AM |
42 | TmfEventsEditor editor = (TmfEventsEditor) activeEditor; |
43 | editor.addBookmark(); | |
be222f56 | 44 | } |
a0a88f65 AM |
45 | return null; |
46 | } | |
be222f56 PT |
47 | |
48 | } |