|
1 /* |
|
2 * Copyright (c) 2008 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 */ |
|
17 |
|
18 package com.nokia.s60tools.crashanalyser.ui.preferences; |
|
19 |
|
20 import org.eclipse.jface.preference.IPreferenceStore; |
|
21 import org.eclipse.jface.preference.PreferencePage; |
|
22 import org.eclipse.swt.SWT; |
|
23 import org.eclipse.swt.layout.GridLayout; |
|
24 import org.eclipse.swt.layout.GridData; |
|
25 import org.eclipse.swt.widgets.Composite; |
|
26 import org.eclipse.swt.widgets.Control; |
|
27 import org.eclipse.ui.IWorkbench; |
|
28 import org.eclipse.ui.IWorkbenchPreferencePage; |
|
29 import org.eclipse.ui.PlatformUI; |
|
30 import org.eclipse.swt.widgets.Button; |
|
31 import org.eclipse.swt.widgets.Group; |
|
32 import com.nokia.s60tools.crashanalyser.plugin.*; |
|
33 import com.nokia.s60tools.crashanalyser.resources.HelpContextIDs; |
|
34 import com.nokia.s60tools.crashanalyser.model.*; |
|
35 import org.eclipse.swt.events.*; |
|
36 |
|
37 /** |
|
38 * Crash Analyser preferences page |
|
39 * |
|
40 */ |
|
41 public class CrashAnalyserPreferences extends PreferencePage implements IWorkbenchPreferencePage, |
|
42 SelectionListener{ |
|
43 private Button buttonListenTraceViewer; |
|
44 private Button buttonShowVisualizer; |
|
45 private Button buttonEpocwind; |
|
46 |
|
47 /** |
|
48 * Constructor |
|
49 */ |
|
50 public CrashAnalyserPreferences() { |
|
51 super(); |
|
52 } |
|
53 |
|
54 public void init(IWorkbench arg0) { |
|
55 // No implementation needed |
|
56 } |
|
57 |
|
58 @Override |
|
59 protected Control createContents(Composite parent) { |
|
60 Composite container = new Composite(parent, SWT.NULL); |
|
61 GridLayout gridLayout = new GridLayout(); |
|
62 gridLayout.numColumns = 1; |
|
63 container.setLayout(gridLayout); |
|
64 |
|
65 Group emulatorGroup = new Group(container, SWT.NONE); |
|
66 emulatorGroup.setLayout(gridLayout); |
|
67 emulatorGroup.setText("WINSCW Emulator Support"); |
|
68 emulatorGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
|
69 |
|
70 buttonEpocwind = new Button(emulatorGroup, SWT.CHECK); |
|
71 buttonEpocwind.setToolTipText("Automatically pick-up panics from epocwind.out while running the Emulator"); |
|
72 buttonEpocwind.setText("Listen panics from epocwind.out"); |
|
73 |
|
74 Group hardwareGroup = new Group(container, SWT.NONE); |
|
75 hardwareGroup.setLayout(gridLayout); |
|
76 hardwareGroup.setText("Target Hardware Support"); |
|
77 hardwareGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
|
78 |
|
79 buttonListenTraceViewer = new Button(hardwareGroup, SWT.CHECK); |
|
80 buttonListenTraceViewer.setToolTipText("Listens for MobileCrash files while tracing e.g. with Profiler Activator or Trace Viewer."); |
|
81 buttonListenTraceViewer.setText("Listen MobileCrash panics via TraceViewer"); |
|
82 buttonListenTraceViewer.addSelectionListener(this); |
|
83 |
|
84 buttonShowVisualizer = new Button(hardwareGroup, SWT.CHECK); |
|
85 buttonShowVisualizer.setToolTipText("When a MobileCrash panic is read via TraceViewer, automatically show panic data"); |
|
86 buttonShowVisualizer.setText("Show Crash Visualiser when crash occurs"); |
|
87 GridData gd = new GridData(); |
|
88 gd.horizontalIndent = 20; |
|
89 buttonShowVisualizer.setLayoutData(gd); |
|
90 |
|
91 if (!TraceListener.traceProviderAvailable()) |
|
92 hardwareGroup.setVisible(false); |
|
93 |
|
94 getPrefsStoreValues(); |
|
95 |
|
96 setHelps(); |
|
97 |
|
98 return container; |
|
99 } |
|
100 |
|
101 private void getPrefsStoreValues(){ |
|
102 IPreferenceStore store = CrashAnalyserPlugin.getCrashAnalyserPrefsStore(); |
|
103 boolean listener = store.getBoolean(CrashAnalyserPreferenceConstants.TRACE_LISTENER); |
|
104 buttonListenTraceViewer.setSelection(listener); |
|
105 |
|
106 boolean epocwind = store.getBoolean(CrashAnalyserPreferenceConstants.EPOCWIND_LISTENER); |
|
107 buttonEpocwind.setSelection(epocwind); |
|
108 |
|
109 boolean showVisualizer = store.getBoolean(CrashAnalyserPreferenceConstants.SHOW_VISUALIZER); |
|
110 buttonShowVisualizer.setSelection(showVisualizer); |
|
111 buttonShowVisualizer.setEnabled(listener); |
|
112 } |
|
113 |
|
114 @Override |
|
115 protected void performDefaults() { |
|
116 buttonListenTraceViewer.setSelection(true); |
|
117 buttonShowVisualizer.setSelection(true); |
|
118 buttonShowVisualizer.setEnabled(true); |
|
119 buttonEpocwind.setSelection(false); |
|
120 super.performDefaults(); |
|
121 } |
|
122 |
|
123 @Override |
|
124 public boolean performOk() { |
|
125 IPreferenceStore store = CrashAnalyserPlugin.getCrashAnalyserPrefsStore(); |
|
126 |
|
127 store.setValue(CrashAnalyserPreferenceConstants.TRACE_LISTENER, buttonListenTraceViewer.getSelection()); |
|
128 store.setValue(CrashAnalyserPreferenceConstants.EPOCWIND_LISTENER, buttonEpocwind.getSelection()); |
|
129 store.setValue(CrashAnalyserPreferenceConstants.SHOW_VISUALIZER, buttonShowVisualizer.getSelection()); |
|
130 |
|
131 CrashAnalyserPlugin.startEmulatorListener(); |
|
132 CrashAnalyserPlugin.startTraceListener(); |
|
133 |
|
134 return super.performOk(); |
|
135 } |
|
136 |
|
137 public void widgetDefaultSelected(SelectionEvent arg0) { |
|
138 // No implementation needed |
|
139 } |
|
140 |
|
141 public void widgetSelected(SelectionEvent event) { |
|
142 if (buttonListenTraceViewer.getSelection()) { |
|
143 buttonShowVisualizer.setEnabled(true); |
|
144 } else { |
|
145 buttonShowVisualizer.setEnabled(false); |
|
146 buttonShowVisualizer.setSelection(false); |
|
147 } |
|
148 } |
|
149 |
|
150 public static boolean traceListenerOn() { |
|
151 IPreferenceStore store = CrashAnalyserPlugin.getCrashAnalyserPrefsStore(); |
|
152 return store.getBoolean(CrashAnalyserPreferenceConstants.TRACE_LISTENER); |
|
153 } |
|
154 |
|
155 public static boolean epocwindListenerOn() { |
|
156 IPreferenceStore store = CrashAnalyserPlugin.getCrashAnalyserPrefsStore(); |
|
157 return store.getBoolean(CrashAnalyserPreferenceConstants.EPOCWIND_LISTENER); |
|
158 } |
|
159 |
|
160 public static boolean showVisualizer() { |
|
161 IPreferenceStore store = CrashAnalyserPlugin.getCrashAnalyserPrefsStore(); |
|
162 return store.getBoolean(CrashAnalyserPreferenceConstants.SHOW_VISUALIZER); |
|
163 } |
|
164 |
|
165 /** |
|
166 * Sets this page's context sensitive helps |
|
167 * |
|
168 */ |
|
169 protected void setHelps() { |
|
170 PlatformUI.getWorkbench().getHelpSystem().setHelp(buttonListenTraceViewer, |
|
171 HelpContextIDs.CRASH_ANALYSER_HELP_PREFERENCES); |
|
172 PlatformUI.getWorkbench().getHelpSystem().setHelp(buttonEpocwind, |
|
173 HelpContextIDs.CRASH_ANALYSER_HELP_PREFERENCES); |
|
174 PlatformUI.getWorkbench().getHelpSystem().setHelp(buttonShowVisualizer, |
|
175 HelpContextIDs.CRASH_ANALYSER_HELP_PREFERENCES); |
|
176 } |
|
177 |
|
178 } |