|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 * Base class for all editor actions of Trace Builder |
|
17 * |
|
18 */ |
|
19 package com.nokia.tracebuilder.action; |
|
20 |
|
21 import org.eclipse.jface.action.IAction; |
|
22 import org.eclipse.jface.viewers.ISelection; |
|
23 import org.eclipse.ui.IEditorActionDelegate; |
|
24 import org.eclipse.ui.IEditorPart; |
|
25 |
|
26 import com.nokia.tracebuilder.engine.TraceBuilderGlobals; |
|
27 import com.nokia.tracebuilder.model.TraceBuilderException; |
|
28 |
|
29 /** |
|
30 * Base class for all editor actions of Trace Builder |
|
31 * |
|
32 */ |
|
33 public abstract class TraceBuilderEditorAction implements IEditorActionDelegate { |
|
34 |
|
35 /* |
|
36 * (non-Javadoc) |
|
37 * |
|
38 * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, |
|
39 * org.eclipse.ui.IEditorPart) |
|
40 */ |
|
41 public void setActiveEditor(IAction action, IEditorPart targetEditor) { |
|
42 } |
|
43 |
|
44 /* |
|
45 * (non-Javadoc) |
|
46 * |
|
47 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) |
|
48 */ |
|
49 public void run(IAction action) { |
|
50 try { |
|
51 doRun(); |
|
52 } catch (TraceBuilderException e) { |
|
53 TraceBuilderGlobals.getEvents().postError(e); |
|
54 } |
|
55 } |
|
56 |
|
57 /* |
|
58 * (non-Javadoc) |
|
59 * |
|
60 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, |
|
61 * org.eclipse.jface.viewers.ISelection) |
|
62 */ |
|
63 public void selectionChanged(IAction action, ISelection selection) { |
|
64 } |
|
65 |
|
66 /** |
|
67 * Runs this action |
|
68 * |
|
69 * @throws TraceBuilderException |
|
70 * if processing fails, shows an error dialog based on the |
|
71 * exception content |
|
72 */ |
|
73 protected abstract void doRun() throws TraceBuilderException; |
|
74 |
|
75 } |