|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 package com.symbian.smt.gui.editors.svgeditor; |
|
16 |
|
17 import org.eclipse.ui.IActionBars; |
|
18 import org.eclipse.ui.IEditorPart; |
|
19 import org.eclipse.ui.IWorkbenchPage; |
|
20 import org.eclipse.ui.IWorkbenchPart; |
|
21 import org.eclipse.ui.actions.ActionFactory; |
|
22 import org.eclipse.ui.actions.LabelRetargetAction; |
|
23 import org.eclipse.ui.part.EditorActionBarContributor; |
|
24 |
|
25 import com.symbian.smt.gui.print.PrintAction; |
|
26 |
|
27 public class SVGEditorContributor extends EditorActionBarContributor { |
|
28 |
|
29 private LabelRetargetAction printRetargetAction; |
|
30 |
|
31 private PrintAction printAction; |
|
32 |
|
33 public SVGEditorContributor() { |
|
34 printAction = new PrintAction("Print SVG"); |
|
35 printRetargetAction = new LabelRetargetAction(ActionFactory.PRINT |
|
36 .getId(), "Print SVG"); |
|
37 } |
|
38 |
|
39 public void dispose() { |
|
40 // Remove retarget actions as page listeners |
|
41 getPage().removePartListener(printRetargetAction); |
|
42 } |
|
43 |
|
44 public void init(IActionBars bars, IWorkbenchPage page) { |
|
45 super.init(bars, page); |
|
46 bars.setGlobalActionHandler(ActionFactory.PRINT.getId(), printAction); |
|
47 |
|
48 // Hook retarget actions as page listeners |
|
49 page.addPartListener(printRetargetAction); |
|
50 IWorkbenchPart activePart = page.getActivePart(); |
|
51 if (activePart != null) { |
|
52 printRetargetAction.partActivated(activePart); |
|
53 |
|
54 } |
|
55 } |
|
56 |
|
57 public void setActiveEditor(IEditorPart editor) { |
|
58 printAction.setActiveEditor(editor); |
|
59 } |
|
60 } |