|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 package com.nokia.s60tools.memspy.ui.wizards; |
|
21 import org.eclipse.swt.SWT; |
|
22 import org.eclipse.swt.layout.GridData; |
|
23 import org.eclipse.swt.layout.GridLayout; |
|
24 import org.eclipse.swt.widgets.Button; |
|
25 import org.eclipse.swt.widgets.Composite; |
|
26 import org.eclipse.swt.widgets.Group; |
|
27 import org.eclipse.ui.PlatformUI; |
|
28 |
|
29 import com.nokia.s60tools.memspy.model.UserEnteredData; |
|
30 import com.nokia.s60tools.memspy.model.UserEnteredData.ValueTypes; |
|
31 import com.nokia.s60tools.memspy.resources.HelpContextIDs; |
|
32 import com.nokia.s60tools.ui.wizards.S60ToolsWizardPage; |
|
33 |
|
34 public class SelectActionPage extends S60ToolsWizardPage{ |
|
35 |
|
36 // Available actions |
|
37 public enum MemSpyAction{IMPORT_HEAP, COMPARE_HEAPS, SWMT} |
|
38 |
|
39 // UI components |
|
40 public Button importHeapRadioButton; |
|
41 public Button compareTwoHeapsRadioButton; |
|
42 public Button swmtRadioButton; |
|
43 |
|
44 /* |
|
45 * (non-Javadoc) |
|
46 * @see com.nokia.s60tools.ui.wizards.S60ToolsWizardPage#setInitialFocus() |
|
47 */ |
|
48 public void setInitialFocus() { |
|
49 } |
|
50 |
|
51 public void recalculateButtonStates() { |
|
52 } |
|
53 |
|
54 |
|
55 protected SelectActionPage(String pageName) { |
|
56 super(pageName); |
|
57 setTitle("MemSpy Import Wizard, First step"); |
|
58 setDescription("Select action you wish to perform with MemSpy."); |
|
59 } |
|
60 public void createControl(Composite parent) { |
|
61 // Radio button group |
|
62 |
|
63 Composite composite = new Composite(parent, SWT.NULL); |
|
64 |
|
65 // create the desired layout for this wizard page |
|
66 GridLayout gl = new GridLayout(); |
|
67 gl.numColumns = 1; |
|
68 composite.setLayout(gl); |
|
69 |
|
70 // Radio Button Group |
|
71 GridLayout radioButtonGroupGridLayout = new GridLayout(); |
|
72 Group radioButtonGroup = new Group (composite, SWT.NONE); |
|
73 radioButtonGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
|
74 radioButtonGroup.setText("Select Action:"); |
|
75 radioButtonGroup.setLayout(radioButtonGroupGridLayout); |
|
76 GridData radioButtonGridData = new GridData(GridData.FILL_HORIZONTAL); |
|
77 radioButtonGridData.horizontalSpan = 2; |
|
78 |
|
79 // Import Heap wizard radio button |
|
80 importHeapRadioButton = new Button(radioButtonGroup, SWT.RADIO); |
|
81 importHeapRadioButton.setText("Import heap and analyse log with Heap Analyser"); |
|
82 importHeapRadioButton.setLayoutData(radioButtonGridData); |
|
83 |
|
84 // Compare Two Heaps radio button |
|
85 compareTwoHeapsRadioButton = new Button(radioButtonGroup, SWT.RADIO); |
|
86 compareTwoHeapsRadioButton.setText("Import heaps and compare logs with Heap Analyser"); |
|
87 compareTwoHeapsRadioButton.setLayoutData(radioButtonGridData); |
|
88 |
|
89 // SWMT wizard radio button |
|
90 swmtRadioButton = new Button(radioButtonGroup, SWT.RADIO); |
|
91 swmtRadioButton.setText("Import System Wide Memory Tracking logs and analyse them with SWMT Analyser"); |
|
92 swmtRadioButton.setLayoutData(radioButtonGridData); |
|
93 |
|
94 // restore previous value of radio button. |
|
95 // if last value is not found, set selection to import heap |
|
96 |
|
97 UserEnteredData data = new UserEnteredData(); |
|
98 int lastUsed = data.getPreviousRadioButtonSelection(ValueTypes.SELECT_ACTION); |
|
99 |
|
100 if( lastUsed == 2 ){ |
|
101 compareTwoHeapsRadioButton.setSelection(true); |
|
102 } |
|
103 else if( lastUsed == 3 ){ |
|
104 swmtRadioButton.setSelection(true); |
|
105 } |
|
106 else { |
|
107 importHeapRadioButton.setSelection(true); |
|
108 } |
|
109 |
|
110 setHelps(); |
|
111 setInitialFocus(); |
|
112 setControl(composite); |
|
113 } |
|
114 |
|
115 /** |
|
116 * getAction |
|
117 * @return currently selected action |
|
118 */ |
|
119 public MemSpyAction getAction(){ |
|
120 if( importHeapRadioButton.getSelection() ){ |
|
121 return MemSpyAction.IMPORT_HEAP; |
|
122 } |
|
123 else if( compareTwoHeapsRadioButton.getSelection() ){ |
|
124 return MemSpyAction.COMPARE_HEAPS; |
|
125 } |
|
126 else{ |
|
127 return MemSpyAction.SWMT; |
|
128 } |
|
129 |
|
130 } |
|
131 |
|
132 |
|
133 /** |
|
134 * saves user entered data from UI components so that it can be restored later. |
|
135 */ |
|
136 public void saveUserEnteredData(){ |
|
137 UserEnteredData data = new UserEnteredData(); |
|
138 |
|
139 // Save Action radio-buttons state |
|
140 if( compareTwoHeapsRadioButton.getSelection() ){ |
|
141 data.saveRadioButtonSelection(ValueTypes.SELECT_ACTION, 2); |
|
142 } |
|
143 else if( swmtRadioButton.getSelection() ){ |
|
144 data.saveRadioButtonSelection(ValueTypes.SELECT_ACTION, 3); |
|
145 } |
|
146 else { |
|
147 data.saveRadioButtonSelection(ValueTypes.SELECT_ACTION, 1); |
|
148 } |
|
149 } |
|
150 |
|
151 /** |
|
152 * canFlipPreviousPage |
|
153 * returns always false because this is first page of wizard. |
|
154 */ |
|
155 public boolean canFlipPreviousPage(){ |
|
156 return false; |
|
157 } |
|
158 |
|
159 /** |
|
160 * Sets this page's context sensitive helps |
|
161 * |
|
162 */ |
|
163 protected void setHelps() { |
|
164 PlatformUI.getWorkbench().getHelpSystem().setHelp( importHeapRadioButton, HelpContextIDs.MEMSPY_SELECT_ACTION); |
|
165 PlatformUI.getWorkbench().getHelpSystem().setHelp( compareTwoHeapsRadioButton, HelpContextIDs.MEMSPY_SELECT_ACTION); |
|
166 PlatformUI.getWorkbench().getHelpSystem().setHelp( swmtRadioButton, HelpContextIDs.MEMSPY_SELECT_ACTION); |
|
167 PlatformUI.getWorkbench().getHelpSystem().setHelp( this.getShell(), HelpContextIDs.MEMSPY_SELECT_ACTION); |
|
168 |
|
169 } |
|
170 |
|
171 } |
|
172 |