|
1 /* |
|
2 * Copyright (c) 2008-2009 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: Definitions for the class ActivateTrace |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 package com.nokia.s60tools.analyzetool; |
|
20 |
|
21 import org.eclipse.ui.IStartup; |
|
22 import org.eclipse.core.runtime.*; |
|
23 import com.nokia.s60tools.analyzetool.ui.IActionListener; |
|
24 import com.nokia.s60tools.analyzetool.ui.MainView; |
|
25 |
|
26 /** |
|
27 * Checks at plugin startup is trace plugin available |
|
28 * and sets MainView trace actions state |
|
29 * @author kihe |
|
30 * |
|
31 */ |
|
32 public class ActivateTrace implements IStartup { |
|
33 |
|
34 /** |
|
35 * Check is AnalyzeTool trace plugin registered. |
|
36 * |
|
37 * If not registered disables AnalyzeTool trace buttons. |
|
38 * |
|
39 * @see org.eclipse.ui.IStartup#earlyStartup() |
|
40 */ |
|
41 public final void earlyStartup() { |
|
42 |
|
43 //get action listener |
|
44 final IActionListener listener = Activator.getActionListener(); |
|
45 |
|
46 //get extension registry |
|
47 IExtensionRegistry registry = RegistryFactory.getRegistry(); |
|
48 if( registry == null ) { |
|
49 MainView.enableTrace = false; |
|
50 if(listener != null) { |
|
51 listener.disableTraceActions(false); |
|
52 } |
|
53 return; |
|
54 } |
|
55 |
|
56 //get analyzetool extension |
|
57 final IExtensionPoint extensionPoint = registry.getExtensionPoint("com.nokia.s60tools.analyzetool.AnalyzeTool"); |
|
58 |
|
59 //try find analyzetool trace extension |
|
60 IExtension extension = null; |
|
61 if( extensionPoint != null ) { |
|
62 extension = extensionPoint.getExtension("com.nokia.s60tools.analyzetool.trace.ActivateTrace"); |
|
63 } |
|
64 |
|
65 |
|
66 |
|
67 //if trace extension found => enable trace buttons in the MainView |
|
68 if(extension != null && extension.isValid()) { |
|
69 MainView.enableTrace = true; |
|
70 if(listener != null) { |
|
71 listener.disableTraceActions(true); |
|
72 } |
|
73 } |
|
74 //no trace extension found => disable trace buttons |
|
75 else { |
|
76 MainView.enableTrace = false; |
|
77 if(listener != null) { |
|
78 listener.disableTraceActions(false); |
|
79 } |
|
80 } |
|
81 |
|
82 } |
|
83 } |