Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 167995 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.properties (-1 / +1 lines)
Lines 17-23 Link Here
17
17
18
JVMTI_ANALYSIS_TYPE_DESCRIPTION_EXEC    = Execution Time Analysis (Java 5.0 +)
18
JVMTI_ANALYSIS_TYPE_DESCRIPTION_EXEC    = Execution Time Analysis (Java 5.0 +)
19
JVMTI_ANALYSIS_TYPE_DESCRIPTION_THRD    = Thread Statistics
19
JVMTI_ANALYSIS_TYPE_DESCRIPTION_THRD    = Thread Statistics
20
JVMTI_ANALYSIS_TYPE_DESCRIPTION_HEAP    = Memory Statistics
20
JVMTI_ANALYSIS_TYPE_DESCRIPTION_HEAP    = Memory Analysis
21
JVMTI_ANALYSIS_TYPE_VIEW_FLOW			= Execution Flow
21
JVMTI_ANALYSIS_TYPE_VIEW_FLOW			= Execution Flow
22
JVMTI_ANALYSIS_TYPE_VIEW_STATISTICS		= Execution Statistics
22
JVMTI_ANALYSIS_TYPE_VIEW_STATISTICS		= Execution Statistics
23
JVMTI_ANALYSIS_TYPE_VIEW_UML_THREAD		= UML2 Thread Interactions
23
JVMTI_ANALYSIS_TYPE_VIEW_UML_THREAD		= UML2 Thread Interactions
(-)plugin.xml (-33 / +27 lines)
Lines 12-25 Link Here
12
		</typeDescription>
12
		</typeDescription>
13
  <typeDescription
13
  <typeDescription
14
        extension="trace"
14
        extension="trace"
15
        icon="icons/full/obj16/exectimeantype_obj.gif"
15
        icon="icons/full/obj16/thread.gif"
16
        name="%JVMTI_ANALYSIS_TYPE_DESCRIPTION_HEAP"
16
        name="%JVMTI_ANALYSIS_TYPE_DESCRIPTION_THRD"
17
        type="org.eclipse.tptp.analysisType.jvmti.heap"/>
17
        type="org.eclipse.tptp.analysisType.jvmti.thread"/>
18
  <typeDescription
18
  <typeDescription
19
        extension="trace"
19
        extension="trace"
20
        icon="icons/full/obj16/exectimeantype_obj.gif"
20
        icon="icons/full/obj16/memleakantype_obj.gif"
21
        name="%JVMTI_ANALYSIS_TYPE_DESCRIPTION_THRD"
21
        name="%JVMTI_ANALYSIS_TYPE_DESCRIPTION_HEAP"
22
        type="org.eclipse.tptp.analysisType.jvmti.thread"/>    
22
        type="org.eclipse.tptp.analysisType.jvmti.heap"/>    
23
	</extension>
23
	</extension>
24
	      
24
	      
25
	<!-- Contribute a view to the TI analysis types -->
25
	<!-- Contribute a view to the TI analysis types -->
Lines 77-89 Link Here
77
            extension="trace">
77
            extension="trace">
78
	    </analyzerExtension>
78
	    </analyzerExtension>
79
       <analyzerExtension
79
       <analyzerExtension
80
             class="org.eclipse.hyades.trace.views.actions.internal.OpenMemoryStatisticViewAction"
81
             extension="trace"
82
             icon="icons/full/obj16/memleakantype_obj.gif"
83
             id="org.eclipse.tptp.platform.jvmti.client.ClassInteractions"
84
             name="%JVMTI_ANALYSIS_TYPE_VIEW_HEAP"
85
             type="org.eclipse.tptp.analysisType.jvmti.heap"/>
86
       <analyzerExtension
87
             class="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenThreadStatisticViewAction"
80
             class="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenThreadStatisticViewAction"
88
             extension="trace"
81
             extension="trace"
89
             icon="icons/full/obj16/thread.gif"
82
             icon="icons/full/obj16/thread.gif"
Lines 99-109 Link Here
99
             type="org.eclipse.tptp.analysisType.jvmti.thread">
92
             type="org.eclipse.tptp.analysisType.jvmti.thread">
100
       </analyzerExtension>
93
       </analyzerExtension>
101
       <analyzerExtension
94
       <analyzerExtension
102
             class="org.eclipse.tptp.trace.jvmti.internal.client.views.MemoryAnalysisViewer"
95
             class="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenMemoryAnalysisViewAction"
103
             extension="org.eclipse.tptp.trace.jvmti.client.analyzerExtension2"
96
             extension="trace"
104
             icon="icons/full/obj16/memleakantype_obj.gif"
97
             icon="icons/full/obj16/memleakantype_obj.gif"
105
             id="org.eclipse.tptp.trace.jvmti.internal.client.views.MemoryAnalysisViewer"
98
             id="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenMemoryAnalysisViewAction"
106
             name="%JVMTI_ANALYSIS_TYPE_VIEW_HEAP_ANALYSIS">
99
             name="%JVMTI_ANALYSIS_TYPE_VIEW_HEAP_ANALYSIS"
100
             type="org.eclipse.tptp.analysisType.jvmti.heap">
107
       </analyzerExtension>
101
       </analyzerExtension>
108
	</extension>
102
	</extension>
109
103
Lines 176-197 Link Here
176
            visible="false"
170
            visible="false"
177
            id="org.eclipse.tptp.trace.jvmti.threadActionSet">
171
            id="org.eclipse.tptp.trace.jvmti.threadActionSet">
178
         <action
172
         <action
179
               label="%JVMTI_ANALYSIS_TYPE_VIEW_THRD"
180
               icon="icons/full/obj16/thread.gif"
181
               tooltip="%JVMTI_ANALYSIS_TYPE_TOOLTIP_THRD"
182
               class="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenThreadStatisticViewAction"
183
               toolbarPath="trace/group.statistic"
184
               id="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenThreadStatisticViewAction">
185
         </action>
186
         <action
187
               class="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenThreadStatesViewAction"
188
               icon="icons/full/cview16/thread_states_view.gif"
189
               id="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenThreadStatesViewAction"
190
               label="%JVMTI_ANALYSIS_TYPE_VIEW_THRD_STATES"
191
               style="push"
192
               toolbarPath="trace/group.statistic"
193
               tooltip="%JVMTI_ANALYSIS_TYPE_TOOLTIP_THRD_STATES"/>
194
         <action
195
               class="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenCallStackViewAction"
173
               class="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenCallStackViewAction"
196
               icon="icons/full/cview16/call_stack_view.gif"
174
               icon="icons/full/cview16/call_stack_view.gif"
197
               id="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenCallStackViewAction"
175
               id="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenCallStackViewAction"
Lines 209-214 Link Here
209
               toolbarPath="trace/group.statistic"
187
               toolbarPath="trace/group.statistic"
210
               tooltip="%JVMTI_ANALYSIS_TYPE_TOOLTIP_HEAP_ANALYSIS">
188
               tooltip="%JVMTI_ANALYSIS_TYPE_TOOLTIP_HEAP_ANALYSIS">
211
         </action>
189
         </action>
190
         <action
191
               class="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenThreadStatesViewAction"
192
               icon="icons/full/cview16/thread_states_view.gif"
193
               id="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenThreadStatesViewAction"
194
               label="%JVMTI_ANALYSIS_TYPE_VIEW_THRD_STATES"
195
               style="push"
196
               toolbarPath="trace/group.statistic"
197
               tooltip="%JVMTI_ANALYSIS_TYPE_TOOLTIP_THRD_STATES"/>
198
         <action
199
               label="%JVMTI_ANALYSIS_TYPE_VIEW_THRD"
200
               icon="icons/full/obj16/thread.gif"
201
               tooltip="%JVMTI_ANALYSIS_TYPE_TOOLTIP_THRD"
202
               class="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenThreadStatisticViewAction"
203
               toolbarPath="trace/group.statistic"
204
               id="org.eclipse.tptp.trace.jvmti.internal.client.views.OpenThreadStatisticViewAction">
205
         </action>
212
      </actionSet>
206
      </actionSet>
213
   </extension>
207
   </extension>
214
    <extension
208
    <extension
(-)src/org/eclipse/tptp/trace/jvmti/internal/client/AllocationSite.java (+43 lines)
Lines 33-36 Link Here
33
		_method = method;
33
		_method = method;
34
		_lineNo = lineNo;
34
		_lineNo = lineNo;
35
	}
35
	}
36
37
	public String getPackageName() {
38
		String name = null;
39
		if (_method != null && _method.getDefiningClass() != null
40
				&& _method.getDefiningClass().getPackage() != null) {
41
			name = _method.getDefiningClass().getPackage().getName();
42
		}
43
		return name;
44
	}
45
46
	public String getClassName() {
47
		String name = null;
48
		if (_method != null && _method.getDefiningClass() != null) {
49
			name = _method.getDefiningClass().getName();
50
		}
51
		return name;
52
	}
53
54
	public String getMethodName() {
55
		String name = null;
56
		if (_method != null) {
57
			name = _method.getName();
58
		}
59
		return name;
60
	}
61
62
	public void clear() {
63
		_lineNo = 0;
64
		_total = 0;
65
		_sumAges = 0;
66
		_collected = 0;
67
		_totalSize = 0;
68
		_collectedSize = 0;
69
		_method = null;
70
	}
71
72
	public void sumOf(final AllocationSite a) {
73
		_total += a._total;
74
		_sumAges += a._sumAges;
75
		_collected += a._collected;
76
		_totalSize += a._totalSize;
77
		_collectedSize += a._collectedSize;
78
	}
36
}
79
}
(-)src/org/eclipse/tptp/trace/jvmti/internal/client/views/MemoryAnalysisPage.java (-13 / +17 lines)
Lines 20-26 Link Here
20
import org.eclipse.hyades.trace.ui.TraceViewer;
20
import org.eclipse.hyades.trace.ui.TraceViewer;
21
import org.eclipse.hyades.trace.ui.TraceViewerPage;
21
import org.eclipse.hyades.trace.ui.TraceViewerPage;
22
import org.eclipse.hyades.trace.ui.UIPlugin;
22
import org.eclipse.hyades.trace.ui.UIPlugin;
23
import org.eclipse.hyades.trace.views.internal.StatisticView;
23
import org.eclipse.hyades.trace.ui.internal.util.PerftraceUtil;
24
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.custom.CTabFolder;
25
import org.eclipse.swt.custom.CTabFolder;
26
import org.eclipse.swt.custom.CTabItem;
26
import org.eclipse.swt.custom.CTabItem;
Lines 36-49 Link Here
36
	static public final int TAB_ALLOC_DETAILS = 1;
36
	static public final int TAB_ALLOC_DETAILS = 1;
37
37
38
	CTabFolder _tabFolder;
38
	CTabFolder _tabFolder;
39
	StatisticView _views[];
39
	BaseStatisticView _views[];
40
40
41
	public MemoryAnalysisPage(EObject mofObject, TraceViewer viewer) {
41
	public MemoryAnalysisPage(EObject mofObject, TraceViewer viewer) {
42
		super(mofObject, viewer);
42
		super(mofObject, viewer);
43
	}
43
	}
44
44
45
	public void refreshPage() {
45
	public void refreshPage() {
46
		StatisticView view = _views[_tabFolder.getSelectionIndex()];
46
		BaseStatisticView view = _views[_tabFolder.getSelectionIndex()];
47
		view.refresh();
47
		view.refresh();
48
		updateButtons();
48
		updateButtons();
49
	}
49
	}
Lines 53-59 Link Here
53
53
54
	public void update(boolean newPage) {
54
	public void update(boolean newPage) {
55
		if (newPage) {
55
		if (newPage) {
56
			StatisticView view = _views[_tabFolder.getSelectionIndex()];
56
			BaseStatisticView view = _views[_tabFolder.getSelectionIndex()];
57
			view.updateUI(view.getColumnDataList());
57
			view.updateUI(view.getColumnDataList());
58
			updateButtons();
58
			updateButtons();
59
		}
59
		}
Lines 74-86 Link Here
74
			}
74
			}
75
			public void widgetSelected(SelectionEvent e) {
75
			public void widgetSelected(SelectionEvent e) {
76
				updateAllocDetails();
76
				updateAllocDetails();
77
				StatisticView view = _views[_tabFolder.getSelectionIndex()];
77
				BaseStatisticView view = _views[_tabFolder.getSelectionIndex()];
78
				view.updateUI(view.getColumnDataList());
78
				view.updateUI(view.getColumnDataList());
79
				updateButtons();
79
				updateButtons();
80
			}
80
			}
81
		});
81
		});
82
82
83
		_views = new StatisticView[2];
83
		_views = new BaseStatisticView[2];
84
		CTabItem tabItem;
84
		CTabItem tabItem;
85
85
86
		tabItem = new CTabItem(_tabFolder, SWT.NONE);
86
		tabItem = new CTabItem(_tabFolder, SWT.NONE);
Lines 117-123 Link Here
117
117
118
	public int getViewTabViewMode() {
118
	public int getViewTabViewMode() {
119
		int viewMode = -1;
119
		int viewMode = -1;
120
		StatisticView view = _views[_tabFolder.getSelectionIndex()];
120
		BaseStatisticView view = _views[_tabFolder.getSelectionIndex()];
121
		if (view instanceof BaseMemoryStatisticView) {
121
		if (view instanceof BaseMemoryStatisticView) {
122
			BaseMemoryStatisticView view0 = (BaseMemoryStatisticView) view;
122
			BaseMemoryStatisticView view0 = (BaseMemoryStatisticView) view;
123
			viewMode = view0.getViewMode();
123
			viewMode = view0.getViewMode();
Lines 129-135 Link Here
129
		if (TAB_MEMORY_STATS != tab && TAB_ALLOC_DETAILS != tab)
129
		if (TAB_MEMORY_STATS != tab && TAB_ALLOC_DETAILS != tab)
130
			return;
130
			return;
131
		_tabFolder.setSelection(tab);
131
		_tabFolder.setSelection(tab);
132
		StatisticView view = _views[_tabFolder.getSelectionIndex()];
132
		BaseStatisticView view = _views[_tabFolder.getSelectionIndex()];
133
		if (view instanceof BaseMemoryStatisticView) {
133
		if (view instanceof BaseMemoryStatisticView) {
134
			BaseMemoryStatisticView view0 = (BaseMemoryStatisticView) view;
134
			BaseMemoryStatisticView view0 = (BaseMemoryStatisticView) view;
135
			view0.setViewMode(viewMode);
135
			view0.setViewMode(viewMode);
Lines 147-164 Link Here
147
		((MemoryAnalysisViewer) _viewer).updateFilterAppliedDescription();
147
		((MemoryAnalysisViewer) _viewer).updateFilterAppliedDescription();
148
	}
148
	}
149
149
150
	public StatisticView getCurrentView() {
150
	public BaseStatisticView getCurrentView() {
151
		StatisticView view = _views[_tabFolder.getSelectionIndex()];
151
		BaseStatisticView view = _views[_tabFolder.getSelectionIndex()];
152
		return view;
152
		return view;
153
	}
153
	}
154
154
155
	public boolean isShowDelta() {
155
	public boolean isShowDelta() {
156
		StatisticView view = _views[_tabFolder.getSelectionIndex()];
156
		BaseStatisticView view = _views[_tabFolder.getSelectionIndex()];
157
		return view.showingDeltaColumns();
157
		return view.showingDeltaColumns();
158
	}
158
	}
159
159
160
	public boolean isShowPercent() {
160
	public boolean isShowPercent() {
161
		StatisticView view = _views[_tabFolder.getSelectionIndex()];
161
		BaseStatisticView view = _views[_tabFolder.getSelectionIndex()];
162
		return view.isShowPercent();
162
		return view.isShowPercent();
163
	}
163
	}
164
164
Lines 168-174 Link Here
168
	}
168
	}
169
169
170
	void updateAllocDetails() {
170
	void updateAllocDetails() {
171
		StatisticView view = _views[_tabFolder.getSelectionIndex()];
171
		BaseStatisticView view = _views[_tabFolder.getSelectionIndex()];
172
		if (view instanceof AllocationDetailsView) {
172
		if (view instanceof AllocationDetailsView) {
173
			ITraceSelection model = UIPlugin.getDefault().getSelectionModel(getMOFObject());
173
			ITraceSelection model = UIPlugin.getDefault().getSelectionModel(getMOFObject());
174
			if (model.size() > 0) {
174
			if (model.size() > 0) {
Lines 178-181 Link Here
178
				((AllocationDetailsView) view).showAllocDetails(null);
178
				((AllocationDetailsView) view).showAllocDetails(null);
179
		}
179
		}
180
	}
180
	}
181
182
	public boolean isEmpty() {
183
		return PerftraceUtil.getTotalSize(getMOFObject()) <= 0;
184
	}
181
}
185
}
(-)src/org/eclipse/tptp/trace/jvmti/internal/client/views/UIMessages.java (-2 / +7 lines)
Lines 36-41 Link Here
36
	public static String _Stopped;
36
	public static String _Stopped;
37
	public static String _Unknown;
37
	public static String _Unknown;
38
38
39
	// state strings lower case
39
	public static String _not_started;
40
	public static String _not_started;
40
	public static String _running;
41
	public static String _running;
41
	public static String _sleeping;
42
	public static String _sleeping;
Lines 65-71 Link Here
65
	public static String _THREAD_GROUP_NAME;
66
	public static String _THREAD_GROUP_NAME;
66
	public static String _THREAD_START_TIME;
67
	public static String _THREAD_START_TIME;
67
	public static String _THREAD_STOP_TIME;
68
	public static String _THREAD_STOP_TIME;
68
	public static String _DURATION;
69
	public static String _THREAD_STATE;
69
	public static String _THREAD_STATE;
70
	public static String _THREAD_RUNNING_TIME;
70
	public static String _THREAD_RUNNING_TIME;
71
	public static String _THREAD_SLEEPING_TIME;
71
	public static String _THREAD_SLEEPING_TIME;
Lines 74-84 Link Here
74
	public static String _THREAD_DEADLOCKED_TIME;
74
	public static String _THREAD_DEADLOCKED_TIME;
75
	public static String _THREAD_BLOCK_COUNT;
75
	public static String _THREAD_BLOCK_COUNT;
76
	public static String _THREAD_DEADLOCK_COUNT;
76
	public static String _THREAD_DEADLOCK_COUNT;
77
	
78
	public static String _THREAD_MONITOR;
77
	public static String _THREAD_MONITOR;
78
79
	// misc
80
	public static String _Delta;
81
	public static String _ShowAsPercentage;
82
	public static String _ShowDeltaColumns;
79
	public static String _MONITOR_OWNER;
83
	public static String _MONITOR_OWNER;
80
	public static String _TIMEOUT;
84
	public static String _TIMEOUT;
81
	public static String _OBJECT_WAITING_FOR;
85
	public static String _OBJECT_WAITING_FOR;
86
	public static String _DURATION;
82
87
83
	private UIMessages() {
88
	private UIMessages() {
84
		// Do not instantiate
89
		// Do not instantiate
(-)src/org/eclipse/tptp/trace/jvmti/internal/client/views/MemoryAnalysisViewer.java (-2 / +9 lines)
Lines 127-136 Link Here
127
		if (getCurrentPage() instanceof MemoryAnalysisPage)
127
		if (getCurrentPage() instanceof MemoryAnalysisPage)
128
			page = (MemoryAnalysisPage) getCurrentPage();
128
			page = (MemoryAnalysisPage) getCurrentPage();
129
		boolean memStatsTab = null != page && page.getViewTab() == MemoryAnalysisPage.TAB_MEMORY_STATS;
129
		boolean memStatsTab = null != page && page.getViewTab() == MemoryAnalysisPage.TAB_MEMORY_STATS;
130
		boolean memAllocTab = null != page && page.getViewTab() == MemoryAnalysisPage.TAB_ALLOC_DETAILS;
130
		boolean classMode = memStatsTab && page.getViewTabViewMode() == BaseMemoryStatisticView.CLASS_MODE;
131
		boolean classMode = memStatsTab && page.getViewTabViewMode() == BaseMemoryStatisticView.CLASS_MODE;
131
		boolean packageMode = memStatsTab && page.getViewTabViewMode() == BaseMemoryStatisticView.PACKAGE_MODE;
132
		boolean packageMode = memStatsTab && page.getViewTabViewMode() == BaseMemoryStatisticView.PACKAGE_MODE;
132
		boolean isDelta = memStatsTab && page.isShowDelta();
133
		boolean isDelta = memStatsTab && page.isShowDelta();
133
		boolean isPercent = memStatsTab && page.isShowPercent();
134
		boolean isPercent = null != page && page.isShowPercent();
134
		_viewClass.setEnabled(memStatsTab);
135
		_viewClass.setEnabled(memStatsTab);
135
		_viewClass.setChecked(classMode);
136
		_viewClass.setChecked(classMode);
136
		_viewPackage.setEnabled(memStatsTab);
137
		_viewPackage.setEnabled(memStatsTab);
Lines 138-146 Link Here
138
		boolean canSrc = null != page && Utils.canOpenSourceOnThisObject(page.getMOFObject());
139
		boolean canSrc = null != page && Utils.canOpenSourceOnThisObject(page.getMOFObject());
139
		_openSource.setEnabled(canSrc);
140
		_openSource.setEnabled(canSrc);
140
		_deltaColumns.setEnabled(memStatsTab);
141
		_deltaColumns.setEnabled(memStatsTab);
141
		_percentMode.setEnabled(memStatsTab);
142
		_percentMode.setEnabled(memAllocTab || memStatsTab);
142
		_deltaColumns.setChecked(isDelta);
143
		_deltaColumns.setChecked(isDelta);
143
		_percentMode.setChecked(isPercent);
144
		_percentMode.setChecked(isPercent);
145
		setFilterActionEnabled(memStatsTab);
144
	}
146
	}
145
147
146
	void createActions() {
148
	void createActions() {
Lines 216-219 Link Here
216
		manager.add(_percentMode);
218
		manager.add(_percentMode);
217
		manager.add(_deltaColumns);
219
		manager.add(_deltaColumns);
218
	}
220
	}
221
222
	public void setFocus() {
223
		if (getCurrentPage() != null)
224
			getCurrentPage().setFocus();
225
	}
219
}
226
}
(-)src/org/eclipse/tptp/trace/jvmti/internal/client/views/BaseMemoryStatisticView.java (-11 / +24 lines)
Lines 33-46 Link Here
33
import org.eclipse.hyades.trace.views.internal.view.columnlabels.ColumnDisplayInfo;
33
import org.eclipse.hyades.trace.views.internal.view.columnlabels.ColumnDisplayInfo;
34
import org.eclipse.hyades.trace.views.internal.view.columnlabels.ColumnLabelAdapter;
34
import org.eclipse.hyades.trace.views.internal.view.columnlabels.ColumnLabelAdapter;
35
import org.eclipse.hyades.trace.views.util.internal.ColumnData;
35
import org.eclipse.hyades.trace.views.util.internal.ColumnData;
36
import org.eclipse.hyades.trace.views.util.internal.StatisticTableColumnInfo;
36
import org.eclipse.jface.viewers.ISelection;
37
import org.eclipse.jface.viewers.StructuredViewer;
38
import org.eclipse.jface.viewers.TreeViewer;
39
import org.eclipse.jface.viewers.Viewer;
37
import org.eclipse.jface.viewers.Viewer;
40
import org.eclipse.swt.events.SelectionEvent;
38
import org.eclipse.swt.events.SelectionEvent;
41
import org.eclipse.swt.graphics.Image;
39
import org.eclipse.swt.graphics.Image;
42
import org.eclipse.swt.widgets.Composite;
40
import org.eclipse.swt.widgets.Composite;
43
import org.eclipse.swt.widgets.Tree;
44
import org.eclipse.tptp.trace.jvmti.internal.client.context.TIContextAttributes;
41
import org.eclipse.tptp.trace.jvmti.internal.client.context.TIContextAttributes;
45
import org.eclipse.tptp.trace.jvmti.internal.client.context.TIContextUpdaterHelper;
42
import org.eclipse.tptp.trace.jvmti.internal.client.context.TIContextUpdaterHelper;
46
import org.eclipse.tptp.trace.jvmti.internal.client.views.columnlabels.LiveSizeLabelAdapter;
43
import org.eclipse.tptp.trace.jvmti.internal.client.views.columnlabels.LiveSizeLabelAdapter;
Lines 177-183 Link Here
177
			_collectedInst = PerftraceUtil.getTotalCollectedInstances(_page.getMOFObject());
174
			_collectedInst = PerftraceUtil.getTotalCollectedInstances(_page.getMOFObject());
178
			if (_collectedInst < 1)
175
			if (_collectedInst < 1)
179
				_collectedInst = 1;
176
				_collectedInst = 1;
180
			//TODO _totalAge = get total age
181
			if (_totalAge < 1)
177
			if (_totalAge < 1)
182
				_totalAge = 1;
178
				_totalAge = 1;
183
		}
179
		}
Lines 202-208 Link Here
202
	}
198
	}
203
199
204
	public String getColumnText(Object element, int columnIndex) {
200
	public String getColumnText(Object element, int columnIndex) {
205
		StatisticTableColumnInfo info = StatisticTableColumnInfo.getStatisticTableColumnInfo(getTree().getColumn(columnIndex));
201
		StatisticViewColumnInfo info = StatisticViewColumnInfo.getStatisticTableColumnInfo(getTree().getColumn(columnIndex));
206
		int pos = info.getColumnData().getInitalPos();
202
		int pos = info.getColumnData().getInitalPos();
207
		String label = "placeholder(view)";
203
		String label = "placeholder(view)";
208
		ColumnLabelAdapter columnAdapter = getColumnsLabelProvider(pos);
204
		ColumnLabelAdapter columnAdapter = getColumnsLabelProvider(pos);
Lines 212-218 Link Here
212
	}
208
	}
213
209
214
	public Image getColumnImage(Object element, int columnIndex) {
210
	public Image getColumnImage(Object element, int columnIndex) {
215
		StatisticTableColumnInfo info = StatisticTableColumnInfo.getStatisticTableColumnInfo(getTree().getColumn(columnIndex));
211
		StatisticViewColumnInfo info = StatisticViewColumnInfo.getStatisticTableColumnInfo(getTree().getColumn(columnIndex));
216
		int pos = info.getColumnData().getInitalPos();
212
		int pos = info.getColumnData().getInitalPos();
217
		Image image = null;
213
		Image image = null;
218
		ColumnLabelAdapter columnAdapter = getColumnsLabelProvider(pos);
214
		ColumnLabelAdapter columnAdapter = getColumnsLabelProvider(pos);
Lines 293-305 Link Here
293
289
294
	void updateAgeInfo(Object arr[]) {
290
	void updateAgeInfo(Object arr[]) {
295
		_ageMap.clear();
291
		_ageMap.clear();
292
		_totalAge = 1;
293
		EList listGC = null;
296
		for (int i = 0; i < arr.length; i++) {
294
		for (int i = 0; i < arr.length; i++) {
297
			if (arr[i] instanceof TRCClass) {
295
			if (arr[i] instanceof TRCClass) {
298
				TRCClass cls = (TRCClass) arr[i];
296
				TRCClass cls = (TRCClass) arr[i];
297
				if (cls.getTotalInstances() == 0)
298
					continue;
299
				AgeInfo ageInfo = new AgeInfo();
299
				AgeInfo ageInfo = new AgeInfo();
300
				EList listGC = cls.getPackage().getProcess().getGcEvents();
300
				if (listGC == null)
301
					listGC = cls.getPackage().getProcess().getGcEvents();
301
				if (null == listGC || listGC.size() == 0)
302
				if (null == listGC || listGC.size() == 0)
302
					return;
303
					return;
304
				_totalAge = listGC.size();
303
				EList list = cls.getObjects();
305
				EList list = cls.getObjects();
304
				int len = list.size();
306
				int len = list.size();
305
				for (int j = 0; j < len; j++) {
307
				for (int j = 0; j < len; j++) {
Lines 320-332 Link Here
320
		public int objCount;
322
		public int objCount;
321
	}
323
	}
322
324
323
	protected StructuredViewer createTreeViewer(Composite tree) {
325
	public void update() {
324
		TreeViewer tv = getTreeViewer((Tree) tree);
326
		super.update();
325
		return tv;
327
		if (_page instanceof MemoryAnalysisPage)
328
			((MemoryAnalysisPage) _page).updateFilterAppliedDescription();
329
	}
330
331
	protected void defaultActionForSelection(ISelection selection) {
332
		// none
326
	}
333
	}
327
334
328
	public void widgetDefaultSelected(SelectionEvent event) {
335
	public void widgetDefaultSelected(SelectionEvent event) {
329
		if (_page instanceof MemoryAnalysisPage)
336
		if (_page instanceof MemoryAnalysisPage)
330
			((MemoryAnalysisPage)_page).showAllocDetails();
337
			((MemoryAnalysisPage)_page).showAllocDetails();
331
	}
338
	}
339
340
	protected SimpleSearchQuery getCurrentFilter() {
341
		if (_page instanceof MemoryAnalysisPage)
342
			return ((MemoryAnalysisPage) _page).getCurrentFilter();
343
		return null;
344
	}
332
}
345
}
(-)src/org/eclipse/tptp/trace/jvmti/internal/client/views/BaseStatisticView.java (-115 / +639 lines)
Lines 1-5 Link Here
1
/*****************************************************************************
1
/*****************************************************************************
2
 * Copyright (c) 2007, Intel Corporation.
2
 * Copyright (c) 2007, IBM Corporation, Intel Corporation.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 16-86 Link Here
16
16
17
import java.util.ArrayList;
17
import java.util.ArrayList;
18
18
19
import org.eclipse.emf.ecore.EObject;
19
import org.eclipse.hyades.trace.internal.ui.PDPluginImages;
20
import org.eclipse.hyades.models.hierarchy.extensions.SimpleSearchQuery;
20
import org.eclipse.hyades.trace.ui.IViewSelectionChangedListener;
21
import org.eclipse.hyades.trace.ui.ITraceSelection;
21
import org.eclipse.hyades.trace.ui.ProfileEvent;
22
import org.eclipse.hyades.trace.ui.TraceViewer;
22
import org.eclipse.hyades.trace.ui.TraceViewerPage;
23
import org.eclipse.hyades.trace.ui.TraceViewerPage;
23
import org.eclipse.hyades.trace.ui.UIPlugin;
24
import org.eclipse.hyades.trace.ui.UIPlugin;
24
import org.eclipse.hyades.trace.ui.ViewSelectionChangedEvent;
25
import org.eclipse.hyades.trace.ui.ViewSelectionChangedEvent;
26
import org.eclipse.hyades.trace.views.actions.internal.OpenSourceAction;
25
import org.eclipse.hyades.trace.views.adapter.internal.IContextViewer;
27
import org.eclipse.hyades.trace.views.adapter.internal.IContextViewer;
26
import org.eclipse.hyades.trace.views.internal.ContextInfoContainer;
28
import org.eclipse.hyades.trace.views.adapter.internal.TraceConstants;
27
import org.eclipse.hyades.trace.views.internal.IContextInfoContainerListener;
29
import org.eclipse.hyades.trace.views.internal.TraceUIPlugin;
28
import org.eclipse.hyades.trace.views.internal.StatisticView;
30
import org.eclipse.hyades.trace.views.internal.view.columnlabels.ColumnDisplayInfo;
31
import org.eclipse.hyades.trace.views.internal.view.columnlabels.ColumnLabelAdapter;
32
import org.eclipse.hyades.trace.views.internal.view.columnlabels.ColumnLabelComparator;
29
import org.eclipse.hyades.trace.views.internal.view.columnlabels.ContextUpdaterHelper;
33
import org.eclipse.hyades.trace.views.internal.view.columnlabels.ContextUpdaterHelper;
30
import org.eclipse.hyades.trace.views.util.internal.ColumnData;
34
import org.eclipse.hyades.trace.views.util.internal.ColumnData;
31
import org.eclipse.hyades.ui.provisional.context.ContextManager;
35
import org.eclipse.hyades.ui.util.GridUtil;
32
import org.eclipse.hyades.ui.provisional.context.IContextLanguage;
36
import org.eclipse.hyades.ui.util.HyadesFormToolkit;
37
import org.eclipse.jface.action.Action;
38
import org.eclipse.jface.action.IMenuManager;
39
import org.eclipse.jface.viewers.DoubleClickEvent;
33
import org.eclipse.jface.viewers.IContentProvider;
40
import org.eclipse.jface.viewers.IContentProvider;
41
import org.eclipse.jface.viewers.IDoubleClickListener;
34
import org.eclipse.jface.viewers.ISelection;
42
import org.eclipse.jface.viewers.ISelection;
35
import org.eclipse.jface.viewers.IStructuredSelection;
43
import org.eclipse.jface.viewers.IStructuredSelection;
36
import org.eclipse.jface.viewers.ITableLabelProvider;
44
import org.eclipse.jface.viewers.ITableLabelProvider;
37
import org.eclipse.jface.viewers.ITreeContentProvider;
45
import org.eclipse.jface.viewers.ITreeContentProvider;
38
import org.eclipse.jface.viewers.LabelProvider;
46
import org.eclipse.jface.viewers.LabelProvider;
47
import org.eclipse.jface.viewers.StructuredViewer;
39
import org.eclipse.jface.viewers.TreeViewer;
48
import org.eclipse.jface.viewers.TreeViewer;
40
import org.eclipse.jface.viewers.Viewer;
49
import org.eclipse.jface.viewers.Viewer;
50
import org.eclipse.jface.viewers.ViewerSorter;
51
import org.eclipse.swt.SWT;
52
import org.eclipse.swt.custom.ViewForm;
53
import org.eclipse.swt.events.ControlEvent;
54
import org.eclipse.swt.events.ControlListener;
55
import org.eclipse.swt.events.SelectionEvent;
56
import org.eclipse.swt.events.SelectionListener;
41
import org.eclipse.swt.graphics.Image;
57
import org.eclipse.swt.graphics.Image;
58
import org.eclipse.swt.graphics.Rectangle;
59
import org.eclipse.swt.layout.GridData;
60
import org.eclipse.swt.layout.GridLayout;
42
import org.eclipse.swt.widgets.Composite;
61
import org.eclipse.swt.widgets.Composite;
62
import org.eclipse.swt.widgets.Control;
63
import org.eclipse.swt.widgets.Table;
64
import org.eclipse.swt.widgets.TableColumn;
43
import org.eclipse.swt.widgets.Tree;
65
import org.eclipse.swt.widgets.Tree;
66
import org.eclipse.swt.widgets.TreeColumn;
44
import org.eclipse.swt.widgets.TreeItem;
67
import org.eclipse.swt.widgets.TreeItem;
68
import org.eclipse.tptp.trace.jvmti.internal.client.widgets.Utils;
69
import org.eclipse.ui.PlatformUI;
70
import org.eclipse.ui.forms.widgets.ColumnLayout;
71
72
/**
73
 * This class was ported from StatisticView from hyades project for JVMTI trace client.
74
 * 
75
 * @see org.eclipse.hyades.trace.views.internal.StatisticView
76
 * 
77
 */
78
public abstract class BaseStatisticView implements IViewSelectionChangedListener, SelectionListener, ControlListener {
45
79
46
public abstract class BaseStatisticView extends StatisticView {
80
	static public String PREFERENCE_KEY_PREFIX = "org.eclipse.tptp.trace.jvmti.internal.client.views.stats.";
47
48
	static public String PREFERENCE_KEY_PREFIX = "org.eclipse.tptp.trace.jvmti.internal.client.views.basememstats.";
49
	static public Object _empty[] = new Object[0];
81
	static public Object _empty[] = new Object[0];
50
82
51
	protected ContextInfoContainer _contextInfo;
83
	protected StructuredViewer _viewer;
52
84
	protected Composite _viewContainer;
53
	BaseStatisticView(Composite parent, TraceViewerPage page) {
85
	protected Composite _filterContainer;
54
		super(parent, page);
86
	protected ViewForm _dataPane;
55
	}
87
	protected Composite _viewComp;
56
88
	protected TraceViewerPage _page;
57
	protected Composite createTree(Composite parent, int options) {
89
	protected StatisticSorter _viewerSorter;
58
		final Tree tree = _toolkit.createTree(parent, options);
90
	protected ArrayList _currentColumns = null;
59
		return tree;
91
	protected Action _updateAction;
60
	}
92
	protected Action _showPercent;
61
	
93
	protected Action _deltaColumnsAction;
62
	protected Composite createControl(Composite parent, ArrayList cols) {
94
	protected boolean _newSelection = false;
63
		final Composite vc = super.createControl(parent, cols);
95
	protected boolean _isShowPercent = false;
64
		_contextInfo = new ContextInfoContainer();
96
	protected boolean _deltaColumns = false;
65
		_contextInfo.setViewer((IContextViewer) _page.getTraceViewer());
97
	protected boolean _refresh = false;
66
		_contextInfo.createControl(vc);
98
	protected boolean _firstTime = true;
67
		_contextInfo.addContextInfoContainerListener(new IContextInfoContainerListener() {
99
	protected double _maxTime;
68
					public void visibilityChanged(boolean isVisible) {
100
	protected int _totalInst;
69
						vc.layout(true, true);
101
	protected int _totalCalls;
70
					}
102
	protected int _activeInst;
71
				});
103
	protected long _totalSize;
72
		return vc;
104
	protected long _activeSize;
73
	}
105
	protected int _collectedInst;
106
	protected HyadesFormToolkit _toolkit;
74
107
75
	protected abstract String getColumnsPreferencesKey();
108
	protected abstract String getColumnsPreferencesKey();
76
	protected abstract String getViewTypeStr();
77
	protected abstract String getDefaultColumnsTemplate();
109
	protected abstract String getDefaultColumnsTemplate();
110
	protected abstract String getViewTypeStr();
111
	protected abstract StatisticSorter getViewerSorterInstance();
78
	protected abstract String getColumnText(Object element, int columnIndex);
112
	protected abstract String getColumnText(Object element, int columnIndex);
79
	protected abstract Image getColumnImage(Object element, int columnIndex);
113
	protected abstract Image getColumnImage(Object element, int columnIndex);
80
	protected abstract Object[] getElements(Object inputElement);
114
	protected abstract Object[] getElements(Object inputElement);
81
	protected abstract boolean hasChildren(Object element);
115
	protected abstract boolean hasChildren(Object element);
82
	protected abstract Object[] getChildren(Object parentElement);
116
	protected abstract Object[] getChildren(Object parentElement);
83
	protected abstract StatisticSorter getViewerSorterInstance();
117
118
	public class BaseStatisticContentProvider implements ITreeContentProvider {
119
120
		public Object[] getChildren(Object parentElement) {
121
			return BaseStatisticView.this.getChildren(parentElement);
122
		}
123
124
		public Object getParent(Object element) {
125
			return null;
126
		}
127
128
		public boolean hasChildren(Object element) {
129
			return BaseStatisticView.this.hasChildren(element);
130
		}
131
132
		public Object[] getElements(Object inputElement) {
133
			return BaseStatisticView.this.getElements(inputElement);
134
		}
135
136
		public void dispose() {
137
		}
138
139
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
140
		}
141
	}
142
143
	class StatisticTreeViewer extends TreeViewer {
144
145
		public StatisticTreeViewer(Tree tree) {
146
			super(tree);
147
		}
148
149
		public void expandItem(TreeItem item) {
150
			item.setExpanded(true);
151
			createChildren(item);
152
		}
153
154
		public ISelection getSelection() {
155
			ISelection sel = super.getSelection();
156
			if (sel != null && !sel.isEmpty()) {
157
			}
158
			return sel;
159
		}
160
	}
161
162
	public abstract class StatisticSorter extends ViewerSorter {
163
		protected TreeColumn _sortColumn;
164
		protected int _sortSequence = -1;
165
		protected StatisticViewColumnInfo _info;
166
		protected int _pos = 0;
167
168
		public StatisticSorter() {
169
			super();
170
		}
171
172
		public void setSortedColumn(TreeColumn newSortColumn) {
173
			// Get the currently designated sort column and turn remove its sorted indicator
174
			TreeColumn currentColumn = getCurrentSortColumn(newSortColumn .getParent());
175
			if (currentColumn != null) {
176
				if (currentColumn == newSortColumn) {
177
					_sortSequence = -_sortSequence;
178
				} else {
179
					_sortSequence = -1;
180
				}
181
			} else {
182
				_sortSequence = 1;
183
			}
184
185
			setSortedColumn(_sortSequence, newSortColumn);
186
		}
187
188
		public void setSortedColumn(int sortSequence, TreeColumn newSortColumn) {
189
			_sortSequence = sortSequence;
190
			_sortColumn = newSortColumn;
191
192
			// Get the currently designated sort column and turn remove its sorted indicator
193
			TreeColumn currentColumn = getCurrentSortColumn(newSortColumn.getParent());
194
			if (currentColumn != null) {
195
				String text = currentColumn.getText();
196
				if (text.startsWith(">") || text.startsWith("<"))
197
					text = text.substring(1);
198
				currentColumn.setText(text);
199
				StatisticViewColumnInfo.getStatisticTableColumnInfo(
200
						currentColumn).setSortColumn(false);
201
			}
202
203
			// Add the sorted indicator to the newly sorted column
204
			String text = newSortColumn.getText();
205
			_info = StatisticViewColumnInfo.getStatisticTableColumnInfo(newSortColumn);
206
			_pos = _info.getColumnData().getInitalPos();
207
			newSortColumn.setText(((_sortSequence > 0) ? ">" : "<") + text);
208
			StatisticViewColumnInfo.getStatisticTableColumnInfo(newSortColumn).setSortColumn(true);
209
		}
210
211
		public int getSortSequence() {
212
			return _sortSequence;
213
		}
214
215
		public void setSortSequence(int sortSequence) {
216
			_sortSequence = sortSequence;
217
		}
218
219
		public TreeColumn getCurrentSortColumn(Tree tree) {
220
			for (int idx = 0; idx < tree.getColumnCount(); idx++) {
221
				if (StatisticViewColumnInfo.getStatisticTableColumnInfo(
222
						tree.getColumn(idx)).isSortColumn()) {
223
					return tree.getColumn(idx);
224
				}
225
			}
226
			return null;
227
		}
228
229
		public TreeColumn resetSortColumn(Tree tree) {
230
			_sortColumn = getCurrentSortColumn(tree);
231
			return _sortColumn;
232
		}
233
	}
234
235
	/** Update action */
236
	class UpdateAction extends Action {
237
		public UpdateAction(String name) {
238
			super(name);
239
			PlatformUI.getWorkbench().getHelpSystem().setHelp(UpdateAction.this, TraceUIPlugin.getPluginId() + ".uvew0000");
240
			PDPluginImages.setImageDescriptors(this, PDPluginImages.T_LCL, PDPluginImages.IMG_UPDATEVIEWS);
241
		}
242
243
		public void run() {
244
			ProfileEvent event = UIPlugin.getDefault().getRefreshViewEvent(_page.getMOFObject());
245
			UIPlugin.getDefault().notifyProfileEventListener(event);
246
		}
247
	}
248
249
	/** Show as percent action */
250
	class ShowPercentAction extends Action {
251
		public ShowPercentAction(String name) {
252
			super(name);
253
			PlatformUI.getWorkbench().getHelpSystem().setHelp(ShowPercentAction.this, TraceUIPlugin.getPluginId() + ".clst0003");
254
		}
255
256
		public void run() {
257
			handlePercentChanged();
258
		}
259
	}
260
261
	/** Show delta columns action */
262
	class DeltaColumnsAction extends Action {
263
		public DeltaColumnsAction(String name) {
264
			super(name);
265
			PlatformUI.getWorkbench().getHelpSystem().setHelp(DeltaColumnsAction.this, TraceUIPlugin.getPluginId() + ".ccol0000");
266
		}
267
268
		public void setChecked(boolean value) {
269
			super.setChecked(value);
270
		}
271
272
		public void run() {
273
			handleDeltaChanged();
274
		}
275
	}
276
277
	protected BaseStatisticView(Composite parent, TraceViewerPage page) {
278
		this(parent, page, true);
279
	}
280
281
	protected BaseStatisticView(Composite parent, TraceViewerPage page, boolean initializeContent) {
282
		_page = page;
283
		PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, getContextHelpId());
284
		if (initializeContent)
285
			createContent(parent);
286
	}
287
288
	public void createContent(Composite parent) {
289
		_toolkit = new HyadesFormToolkit(parent.getDisplay());
290
		_currentColumns = ColumnData.createColumnData(getColumnsPreferencesKey(), getDefaultColumnsTemplate());
291
		_isShowPercent = Utils.loadIntOption(getPreferenceString(TraceConstants.PERCENTAGE)) == 1;
292
		_deltaColumns = Utils.loadIntOption(getPreferenceString(TraceConstants.DELTA)) == 1;
293
		createControl(parent, _currentColumns);
294
	}
295
296
	/*
297
	 * @see SelectionListener#widgetSelected(SelectionEvent)
298
	 */
299
	public void widgetSelected(SelectionEvent arg0) {
300
		if (arg0.widget instanceof TreeColumn) {
301
			_viewerSorter.setSortedColumn((TreeColumn) arg0.widget);
302
			_viewer.setSorter(_viewerSorter);
303
			_viewer.refresh();
304
		} else if (arg0.widget instanceof Table || arg0.widget instanceof Tree) {
305
			updateModelSelection();
306
		}
307
		updateButtons();
308
	}
309
310
	public Tree getTree() {
311
		return (Tree) getTreeViewer().getControl();
312
	}
313
314
	protected TreeViewer getTreeViewer(Tree tree) {
315
		return new StatisticTreeViewer(tree);
316
	}
84
317
85
	protected IContentProvider getContentProvider() {
318
	protected IContentProvider getContentProvider() {
86
		return new BaseStatisticContentProvider();
319
		return new BaseStatisticContentProvider();
Lines 98-174 Link Here
98
		return new StatisticLabelProvider();
331
		return new StatisticLabelProvider();
99
	}
332
	}
100
333
101
	protected void updateButtons() {
334
	protected void defaultActionForSelection(ISelection selection) {
102
		if (_page instanceof MemoryAnalysisPage) {
335
		OpenSourceAction action = new OpenSourceAction();
103
			((MemoryAnalysisPage)_page).updateButtons();
336
		action.selectionChanged(action, selection);
104
		}
337
		action.run();
338
	}
339
340
	protected StructuredViewer createTreeViewer(Composite tree) {
341
		TreeViewer tv = getTreeViewer((Tree) tree);
342
		tv.addDoubleClickListener(new IDoubleClickListener() {
343
			public void doubleClick(DoubleClickEvent event) {
344
				ISelection selection = event.getSelection();
345
				if (selection != null && !selection.isEmpty()) {
346
					TreeViewer tv = (TreeViewer) getTreeViewer();
347
					Object node = ((IStructuredSelection) selection).getFirstElement();
348
					if (tv.isExpandable(node)) {
349
						tv.setExpandedState(node, !tv.getExpandedState(node));
350
					} else {
351
						defaultActionForSelection(selection);
352
					}
353
				}
354
			}
355
		});
356
		return (StructuredViewer) tv;
105
	}
357
	}
106
358
107
	public void update() {
359
	protected Composite getViewComponent() {
108
		if (_page instanceof MemoryAnalysisPage && _contextInfo != null)
360
		return _viewComp;
109
			_contextInfo.setMOFObject(_page.getMOFObject());
110
		super.update();
111
		if (_page instanceof MemoryAnalysisPage)
112
			((MemoryAnalysisPage) _page).updateFilterAppliedDescription();
113
	}
361
	}
114
362
115
	protected void updateStatusContext(IContextLanguage language) {
363
	protected TraceViewerPage getTraceViewerPage() {
116
		if (_contextInfo != null)
364
		return _page;
117
			_contextInfo.updateStatusContext(language);
118
	}
365
	}
119
366
120
	public Tree getTree() {
367
	protected ViewForm getDataPane() {
121
		return (Tree) getTreeViewer().getControl();
368
		return _dataPane;
122
	}
369
	}
123
370
124
	protected TreeViewer getTreeViewer(Tree tree) {
371
	public void showNewSelection() {
125
		return new StatisticTreeViewer(tree);
372
		if (_newSelection) {
373
			getTree().showSelection();
374
			_newSelection = false;
375
		}
126
	}
376
	}
127
377
128
	protected void handleSelectionEvent() {
378
	public boolean showingDeltaColumns() {
129
		ITraceSelection model = UIPlugin.getDefault().getSelectionModel(_page.getMOFObject());
379
		return _deltaColumns;
130
		if (model.size() > 0) {
380
	}
131
			Object sel = model.getFirstElement();
381
132
			if (sel != null) {
382
	protected void setNewSelection() {
133
				select(sel);
383
		_newSelection = true;
134
				if (sel instanceof EObject)
384
	}
135
					updateStatusContext(ContextManager.getContextLanguage(ContextUpdaterHelper.getContext((EObject)sel)));
385
136
			}
386
	public Action getUpdateAction() {
387
		if (_updateAction == null) {
388
			_updateAction = new UpdateAction(UIPlugin.getResourceString("REFRESH_VIEWS"));
137
		}
389
		}
390
		return _updateAction;
138
	}
391
	}
139
392
140
	protected void select(Object obj) {
393
	public Action getDeltaColumnsAction() {
394
		if (_deltaColumnsAction == null) {
395
			_deltaColumnsAction = new DeltaColumnsAction(UIMessages._ShowDeltaColumns);
396
		}
397
		return _deltaColumnsAction;
141
	}
398
	}
142
399
143
	public void updateModelSelection() {
400
	public Action getShowPercentAction() {
144
		ISelection selection = getTreeViewer().getSelection();
401
		if (_showPercent == null) {
145
		if (selection != null && !selection.isEmpty()) {
402
			_showPercent = new ShowPercentAction(UIMessages._ShowAsPercentage);
146
			Object sel = ((IStructuredSelection) selection).getFirstElement();
147
			notifyViewSelectionChanged(this, sel);
148
		}
403
		}
404
		return _showPercent;
149
	}
405
	}
150
406
151
	public void handleViewSelectionChangedEvent(ViewSelectionChangedEvent event) {
407
	public boolean isShowPercent() {
152
		Object source = event.getSource();
408
		return _isShowPercent;
153
		if (source != this) {
409
	}
154
			handleSelectionEvent();
410
155
		} else {
411
	public Control getControl() {
156
			ITraceSelection model = UIPlugin.getDefault().getSelectionModel(_page.getMOFObject());
412
		return _viewContainer;
157
			if (model.size() > 0) {
413
	}
158
				Object sel = model.getFirstElement();
414
159
				if (sel != null && sel instanceof EObject)
415
	public ArrayList getColumnDataList() {
160
					updateStatusContext(ContextManager.getContextLanguage(ContextUpdaterHelper.getContext((EObject)sel)));
416
		return _currentColumns;
161
			}
417
	}
162
			updateButtons();
418
419
	public StructuredViewer getTreeViewer() {
420
		return _viewer;
421
	}
422
423
	public StatisticSorter getViewerSorter() {
424
		return _viewerSorter;
425
	}
426
427
	public void widgetDefaultSelected(SelectionEvent arg0) {
428
	}
429
430
	public void controlMoved(ControlEvent arg0) {
431
	}
432
433
	public void controlResized(ControlEvent arg0) {
434
		// Get the client area for the shell
435
		Rectangle dataBounds = getViewComponent().getClientArea();
436
		getDataPane().setBounds(dataBounds.x, dataBounds.y, dataBounds.width, dataBounds.height);
437
		// If the table column was resized, update the ColumnData array with the
438
		// new size and save the new column definitions to the preferences.
439
		if (arg0.getSource() instanceof TableColumn) {
440
			ColumnData.setColumns(getColumnDataList(), getColumnsPreferencesKey());
163
		}
441
		}
164
	}
442
	}
165
	
443
444
	public void menuAboutToShow(IMenuManager arg0) {
445
	}
446
447
	protected void setRedrawTable(boolean redraw) {
448
		_viewer.getControl().setRedraw(redraw);
449
	}
450
451
	public void refresh() {
452
		if (!getTreeViewer().getControl().isDisposed())
453
			update();
454
	}
455
456
	public void selectionChanged() {
457
		handleSelectionEvent();
458
	}
459
460
	public void updateUI(ArrayList cols) {
461
		update();
462
		updateButtons();
463
	}
464
465
	protected void showPercentUpdate() {
466
	}
467
166
	protected void firstTimeUpdate() {
468
	protected void firstTimeUpdate() {
167
		super.firstTimeUpdate();
469
		_firstTime = false;
470
		Tree tree = getTree();
471
		TreeColumn firstColumn = tree.getColumn(0);
472
		_viewerSorter = getViewerSorterInstance();
473
		_viewerSorter.setSortedColumn(firstColumn);
474
		_viewer.setSorter(_viewerSorter);
168
		redrawTable();
475
		redrawTable();
169
	}
476
	}
170
477
171
	public void redrawTable() {
478
	protected void redrawTable() {
172
		getTree().setRedraw(false);
479
		getTree().setRedraw(false);
173
		_currentColumns = ColumnData.createColumnData(getColumnsPreferencesKey(), getDefaultColumnsTemplate());
480
		_currentColumns = ColumnData.createColumnData(getColumnsPreferencesKey(), getDefaultColumnsTemplate());
174
		_currentColumns = TIColumnData.convertColumnData(_currentColumns);
481
		_currentColumns = TIColumnData.convertColumnData(_currentColumns);
Lines 177-236 Link Here
177
		refresh();
484
		refresh();
178
	}
485
	}
179
486
180
	public class BaseStatisticContentProvider implements ITreeContentProvider {
487
	protected void postUpdateEvents() {
488
		handleSelectionEvent();
489
	}
181
490
182
		public Object[] getChildren(Object parentElement) {
491
	protected void expandFirstElement() {
183
			return BaseStatisticView.this.getChildren(parentElement);
492
	}
184
		}
185
493
186
		public Object getParent(Object element) {
494
	protected String getContext() {
187
			return null;
495
		IContextViewer viewer = getContextViewer();
496
		return viewer != null ? viewer.getSelectedContext() : null;
497
	}
498
499
	protected boolean contextChanged() {
500
		IContextViewer viewer = getContextViewer();
501
		if (viewer != null) {
502
			if (viewer.contextChanged()) {
503
				return true;
504
			} else {
505
				viewer.setSelectedContext(ContextUpdaterHelper.getCurrentContext(ContextUpdaterHelper.getContexts(_page.getMOFObject()), viewer), false);
506
				return viewer.contextChanged();
507
			}
508
		} else
509
			return false;
510
	}
511
512
	protected void updateContext() {
513
		resetColumns(_currentColumns);
514
		IContextViewer viewer = getContextViewer();
515
		if (viewer != null)
516
			viewer.updateContext();
517
	}
518
519
	private IContextViewer getContextViewer() {
520
		if (_page != null) {
521
			TraceViewer traceViewer = _page.getTraceViewer();
522
			if (traceViewer != null && traceViewer instanceof IContextViewer)
523
				return (IContextViewer) traceViewer;
188
		}
524
		}
525
		return null;
526
	}
189
527
190
		public boolean hasChildren(Object element) {
528
	public void update() {
191
			return BaseStatisticView.this.hasChildren(element);
529
		if (_firstTime)
530
			firstTimeUpdate();
531
		// context changes or context handler selection changes
532
		if (contextChanged() || _page.getTraceViewer().contextHandlerSelectionChanged()) {
533
			updateContext();
534
		}
535
		IContextViewer viewer = getContextViewer();
536
		if (viewer != null) {
537
			viewer.getContextSelectionMenuListener().setMOFObject(_page.getMOFObject());
538
		}
539
		// set the input of the viewer
540
		showPercentUpdate();
541
		setRedrawTable(false);
542
		getTreeViewer().setInput(_page.getMOFObject());
543
		// _viewer.refresh();
544
		expandFirstElement();
545
		setRedrawTable(true);
546
		postUpdateEvents();
547
	}
548
549
	/**
550
	 * This method is called as a result of changing the selected columns. It
551
	 * takes the new column definition list and adjusts the columns of the table
552
	 * to match this list.
553
	 */
554
	protected void resetColumns(ArrayList list) {
555
		String sortedColumnKey = ""; // store sorted column
556
		boolean isDeltaColumn = false;
557
		int sortSequence = _viewerSorter.getSortSequence(); // store sorted sequence
558
559
		Tree tree = getTree();
560
		setRedrawTable(false);
561
562
		// Dispose all the existing columns
563
		for (int idx = tree.getColumnCount(); idx > 0; idx--) {
564
			TreeColumn col = tree.getColumn(tree.getColumnCount() - 1);
565
			StatisticViewColumnInfo staticTblColInfo = (StatisticViewColumnInfo) (col.getData());
566
			if (staticTblColInfo.isSortColumn()) {
567
				sortedColumnKey = staticTblColInfo.getColumnData().key();
568
				isDeltaColumn = staticTblColInfo.isDeltaColumn();
569
			}
570
			col.dispose();
192
		}
571
		}
193
572
194
		public Object[] getElements(Object inputElement) {
573
		for (int idx = 0; idx < list.size(); idx++) {
195
			return BaseStatisticView.this.getElements(inputElement);
574
			ColumnData data = (ColumnData) list.get(idx);
575
			data.setContext(getContext());
576
			if (data.visible()) {
577
				new StatisticViewColumnInfo(this, data, _deltaColumns);
578
			}
196
		}
579
		}
197
580
198
		public void dispose() {
581
		tree = getTree();
582
		for (int idx = 0; idx < tree.getColumnCount(); idx++) {
583
			StatisticViewColumnInfo treeColumnInfo = getColumnInfo(tree.getColumn(idx));
584
			if (treeColumnInfo != null
585
					&& sortedColumnKey.equals(treeColumnInfo.getColumnData().key())
586
					&& isDeltaColumn == treeColumnInfo.isDeltaColumn()) {
587
				treeColumnInfo.setSortColumn(true);
588
				break;
589
			}
199
		}
590
		}
200
591
201
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
592
		if (_viewerSorter.resetSortColumn(getTree()) == null) {
593
			_viewer.setSorter(null);
594
		} else {
595
			_viewerSorter.setSortSequence(sortSequence * -1);
596
			_viewerSorter.setSortedColumn(_viewerSorter.resetSortColumn(getTree()));
597
			_viewer.setSorter(_viewerSorter);
202
		}
598
		}
599
600
		setRedrawTable(true);
203
	}
601
	}
204
602
205
	class StatisticTreeViewer extends TreeViewer {
603
	protected Composite createControl(Composite parent, ArrayList cols) {
604
		GridLayout layout;
605
		_viewContainer = _toolkit.createComposite(parent, SWT.FLAT);
606
		layout = new GridLayout();
607
		layout.numColumns = 1;
608
		_viewContainer.setLayout(layout);
609
		_viewContainer.setLayoutData(GridUtil.createFill());
610
		createLabel(_viewContainer);
611
		_viewComp = _toolkit.createComposite(_viewContainer, SWT.FLAT);
612
		layout = new GridLayout();
613
		layout.numColumns = 1;
614
		layout.marginWidth = 0;
615
		layout.marginHeight = 0;
616
		_viewComp.setLayout(layout);
617
		_viewComp.setLayoutData(GridUtil.createFill());
618
		_dataPane = _toolkit.createViewForm(_viewComp);
619
		Control table = createTableViewer(_dataPane, cols);
620
		_dataPane.setContent(table);
621
		_dataPane.setLayoutData(GridUtil.createFill());
622
		_viewContainer.addControlListener(this);
623
		return _viewContainer;
624
	}
625
626
	protected void createLabel(Composite viewContainer) {
627
	}
628
629
	protected Tree createTree(Composite parent, int options) {
630
		Tree tree = _toolkit.createTree(parent, options);
631
		tree.setLinesVisible(true);
632
		tree.setHeaderVisible(true);
633
		ColumnLayout layout = new ColumnLayout();
634
		layout.maxNumColumns = 100;
635
		tree.setLayout(layout);
636
		tree.setLayoutData(new GridData(GridData.FILL_BOTH));
637
		tree.addSelectionListener(this);
638
		return tree;
639
	}
206
640
207
		public StatisticTreeViewer(Tree tree) {
641
	private Control createTableViewer(Composite parent, ArrayList cols) {
208
			super(tree);
642
		Tree tree = createTree(parent, SWT.SINGLE | SWT.FULL_SELECTION | SWT.FLAT);
643
		_viewer = createTreeViewer(tree);
644
		for (int idx = 0; idx < cols.size(); idx++) {
645
			ColumnData data = (ColumnData) cols.get(idx);
646
			data.setContext(getContext());
647
			if (data.visible()) {
648
				new StatisticViewColumnInfo(this, data, _deltaColumns);
649
			}
209
		}
650
		}
651
		_viewer.setContentProvider(getContentProvider());
652
		_viewer.setLabelProvider(getTableLabelProvider());
653
		UIPlugin.getDefault().addViewSelectionChangedListener(this);
654
		return _viewer.getControl();
655
	}
210
656
211
		public void expandItem(TreeItem item) {
657
	public void dispose() {
212
			item.setExpanded(true);
658
		UIPlugin.getDefault().removeViewSelectionChangedListener(this);
213
			createChildren(item);
659
		_page = null;
214
		}
660
	}
215
661
216
		public ISelection getSelection() {
662
	public void handlePercentChanged() {
217
			ISelection sel = super.getSelection();
663
		_isShowPercent = !_isShowPercent;
218
			if (sel != null && !sel.isEmpty()) {
664
		Utils.saveIntOption(getPreferenceString(TraceConstants.PERCENTAGE), (_isShowPercent ? 1 : 0));
219
			}
665
		refresh();
220
			return sel;
666
		updateButtons();
221
		}
222
	}
667
	}
223
668
224
	public class BaseStatisticFilter extends StatisticFilter {
669
	public void handleDeltaChanged() {
670
		_deltaColumns = !_deltaColumns;
671
		Utils.saveIntOption(getPreferenceString(TraceConstants.DELTA), (_deltaColumns ? 1 : 0));
672
		resetColumns(_currentColumns);
673
		refresh();
674
	}
225
675
226
		public boolean select(Viewer viewer, Object parent, Object element) {
676
	protected String getPreferenceString(String str) {
227
			return false;
677
		return getViewTypeStr() + "." + str;
678
	}
679
680
	public void updateModelSelection() {
681
		ISelection selection = getTreeViewer().getSelection();
682
		if (selection != null && !selection.isEmpty()) {
683
			Object sel = ((IStructuredSelection) selection).getFirstElement();
684
			notifyViewSelectionChanged(this, sel);
228
		}
685
		}
229
	}
686
	}
230
687
231
	protected SimpleSearchQuery getCurrentFilter() {
688
	public void notifyViewSelectionChanged(Object source, Object selection) {
232
		if (_page instanceof MemoryAnalysisPage)
689
		UIPlugin.getDefault().getSelectionModel(_page.getMOFObject()).add(selection);
233
			return ((MemoryAnalysisPage) _page).getCurrentFilter();
690
		ViewSelectionChangedEvent event = UIPlugin.getDefault().getViewSelectionChangedEvent();
691
		event.setSource(source);
692
		UIPlugin.getDefault().notifyViewSelectionChangedListener(event);
693
	}
694
695
	public HyadesFormToolkit getToolkit() {
696
		return _toolkit;
697
	}
698
699
	protected StatisticViewColumnInfo getColumnInfo(TreeColumn treeColumn) {
700
		if (treeColumn.getData() != null && treeColumn.getData() instanceof StatisticViewColumnInfo)
701
			return (StatisticViewColumnInfo) treeColumn.getData();
234
		return null;
702
		return null;
235
	}
703
	}
704
705
	protected int compareElements(Object obj1, Object obj2, ColumnLabelAdapter col, boolean isDeltaColumn) {
706
		ColumnDisplayInfo info = getColumnDisplayInfo(col, isDeltaColumn);
707
		return ColumnLabelComparator.compare(obj1, obj2, col, info);
708
	}
709
710
	protected String getElementColumnText(Object obj, ColumnLabelAdapter col, boolean isDeltaColumn) {
711
		ColumnDisplayInfo info = getColumnDisplayInfo(col, isDeltaColumn);
712
		return col.getDisplayString(obj, info);
713
	}
714
715
	protected Image getElementColumnImage(Object obj, ColumnLabelAdapter col, boolean isDeltaColumn) {
716
		ColumnDisplayInfo info = getColumnDisplayInfo(col, isDeltaColumn);
717
		return col.getDisplayImage(obj, info);
718
	}
719
720
	protected ColumnDisplayInfo getColumnDisplayInfo(ColumnLabelAdapter col, boolean isDeltaColumn) {
721
		return col.getColumnDisplayInfo();
722
	}
723
724
	protected String getContextHelpId() {
725
		return null;
726
	}
727
728
	protected void updateButtons() {
729
		if (_page instanceof MemoryAnalysisPage) {
730
			((MemoryAnalysisPage)_page).updateButtons();
731
		}
732
	}
733
734
	protected void handleSelectionEvent() {
735
		/*ITraceSelection model = UIPlugin.getDefault().getSelectionModel(_page.getMOFObject());
736
		if (model.size() > 0) {
737
			Object sel = model.getFirstElement();
738
			if (sel != null) {
739
				//select(sel);
740
				//if (sel instanceof EObject)
741
				//	updateStatusContext(ContextManager.getContextLanguage(ContextUpdaterHelper.getContext((EObject)sel)));
742
			}
743
		}*/
744
	}
745
746
	public void handleViewSelectionChangedEvent(ViewSelectionChangedEvent event) {
747
		Object source = event.getSource();
748
		if (source != this) {
749
			handleSelectionEvent();
750
		} else {
751
			/*ITraceSelection model = UIPlugin.getDefault().getSelectionModel(_page.getMOFObject());
752
			if (model.size() > 0) {
753
				//Object sel = model.getFirstElement();
754
				//if (sel != null && sel instanceof EObject)
755
				//	updateStatusContext(ContextManager.getContextLanguage(ContextUpdaterHelper.getContext((EObject)sel)));
756
			}*/
757
			updateButtons();
758
		}
759
	}
236
}
760
}
(-)src/org/eclipse/tptp/trace/jvmti/internal/client/views/messages.properties (+4 lines)
Lines 69-74 Link Here
69
_THREAD_BLOCK_COUNT = Block Count
69
_THREAD_BLOCK_COUNT = Block Count
70
_THREAD_DEADLOCK_COUNT = Deadlock Count
70
_THREAD_DEADLOCK_COUNT = Deadlock Count
71
71
72
#misc
73
_Delta = Delta
74
_ShowAsPercentage = Show as Percentage
75
_ShowDeltaColumns = Show Delta Columns
72
_THREAD_MONITOR = Monitor
76
_THREAD_MONITOR = Monitor
73
_MONITOR_OWNER = Monitor Owner
77
_MONITOR_OWNER = Monitor Owner
74
_TIMEOUT = Timeout
78
_TIMEOUT = Timeout
(-)src/org/eclipse/tptp/trace/jvmti/internal/client/views/AllocationDetailsView.java (-69 / +88 lines)
Lines 14-20 Link Here
14
14
15
package org.eclipse.tptp.trace.jvmti.internal.client.views;
15
package org.eclipse.tptp.trace.jvmti.internal.client.views;
16
16
17
import java.util.ArrayList;
18
import java.util.HashMap;
17
import java.util.HashMap;
19
import java.util.Map;
18
import java.util.Map;
20
19
Lines 23-32 Link Here
23
import org.eclipse.hyades.models.trace.TRCFullTraceObject;
22
import org.eclipse.hyades.models.trace.TRCFullTraceObject;
24
import org.eclipse.hyades.models.trace.TRCMethod;
23
import org.eclipse.hyades.models.trace.TRCMethod;
25
import org.eclipse.hyades.models.trace.TRCObjectAllocationAnnotation;
24
import org.eclipse.hyades.models.trace.TRCObjectAllocationAnnotation;
26
import org.eclipse.hyades.models.trace.TRCPackage;
27
import org.eclipse.hyades.trace.ui.TraceViewerPage;
25
import org.eclipse.hyades.trace.ui.TraceViewerPage;
26
import org.eclipse.hyades.trace.ui.internal.util.TString;
28
import org.eclipse.hyades.trace.views.util.internal.ColumnData;
27
import org.eclipse.hyades.trace.views.util.internal.ColumnData;
29
import org.eclipse.hyades.trace.views.util.internal.StatisticTableColumnInfo;
30
import org.eclipse.hyades.ui.provisional.context.IContextLabelFormatProvider;
28
import org.eclipse.hyades.ui.provisional.context.IContextLabelFormatProvider;
31
import org.eclipse.hyades.ui.util.GridUtil;
29
import org.eclipse.hyades.ui.util.GridUtil;
32
import org.eclipse.jface.viewers.Viewer;
30
import org.eclipse.jface.viewers.Viewer;
Lines 58-63 Link Here
58
	private TRCClass _class;
56
	private TRCClass _class;
59
	private int _nextIndex;
57
	private int _nextIndex;
60
	private Label _label;
58
	private Label _label;
59
	AllocationSite _allocAll = new AllocationSite();
61
	static final Object _emptyArr[] = new Object[0];
60
	static final Object _emptyArr[] = new Object[0];
62
61
63
	protected AllocationDetailsView(Composite parent, TraceViewerPage page) {
62
	protected AllocationDetailsView(Composite parent, TraceViewerPage page) {
Lines 72-88 Link Here
72
		return "viewoption.allocdetails";
71
		return "viewoption.allocdetails";
73
	}
72
	}
74
	
73
	
75
	protected Composite createControl(Composite parent, ArrayList cols) {
74
	protected void createLabel(Composite viewContainer) {
76
		Composite comp = super.createControl(parent, cols);
75
		_label = _toolkit.createLabel(viewContainer, null);
77
		_label = _toolkit.createLabel(comp, null);
78
		Font font = _label.getFont();
76
		Font font = _label.getFont();
79
		FontData fd = font.getFontData()[0];
77
		FontData fd = font.getFontData()[0];
80
		font = new Font(null, new FontData(fd.getName(), fd.getHeight() * 3 / 2, fd.getStyle()));
78
		font = new Font(null, new FontData(fd.getName(), fd.getHeight() * 3 / 2, fd.getStyle()));
81
		_label.setFont(font);
79
		_label.setFont(font);
82
		_label.setBackground(comp.getBackground());
80
		_label.setBackground(viewContainer.getBackground());
83
		_label.setForeground(new Color(null, 0, 0, 200));
81
		_label.setForeground(new Color(null, 0, 0, 200));
84
		_label.setLayoutData(GridUtil.createHorizontalFill());
82
		_label.setLayoutData(GridUtil.createHorizontalFill());
85
		return comp;
86
	}
83
	}
87
84
88
	protected String getDefaultColumnsTemplate() {
85
	protected String getDefaultColumnsTemplate() {
Lines 100-186 Link Here
100
			;
97
			;
101
	}
98
	}
102
99
100
	String formatPercent(int val, int max) {
101
		String s = max > 0 && max >= val ?
102
			TString.formatAsPercentage((double)val / (double)max) : "";
103
		return s;
104
	}
105
103
	public String getColumnText(Object element, int columnIndex) {
106
	public String getColumnText(Object element, int columnIndex) {
104
		StatisticTableColumnInfo info = StatisticTableColumnInfo
107
		StatisticViewColumnInfo info = StatisticViewColumnInfo
105
				.getStatisticTableColumnInfo(getTree().getColumn(columnIndex));
108
				.getStatisticTableColumnInfo(getTree().getColumn(columnIndex));
106
		int pos = info.getColumnData().getInitalPos();
109
		int pos = info.getColumnData().getInitalPos();
107
		String label = "";
110
		String label = "";
108
		if (!(element instanceof AllocationSite))
111
		if (!(element instanceof AllocationSite))
109
			return label;
112
			return label;
113
		boolean noperc = !isShowPercent();
110
		AllocationSite allocSite = (AllocationSite) element;
114
		AllocationSite allocSite = (AllocationSite) element;
111
		switch (pos) {
115
		switch (pos) {
112
		case AD_COL_METHOD_NAME:
116
		case AD_COL_METHOD_NAME:
113
			if (allocSite._method != null)
117
			label = allocSite.getMethodName();
114
				label = allocSite._method.getName();
115
			break;
118
			break;
116
		case AD_COL_CLASS_NAME:
119
		case AD_COL_CLASS_NAME:
117
			if (allocSite._method != null &&
120
			label = allocSite.getClassName();
118
					allocSite._method.getDefiningClass() != null)
119
				label = allocSite._method.getDefiningClass().getName();
120
			break;
121
			break;
121
		case AD_COL_PACKAGE_NAME:
122
		case AD_COL_PACKAGE_NAME:
122
			if (allocSite._method != null &&
123
			label = allocSite.getPackageName();
123
					allocSite._method.getDefiningClass() != null &&
124
					allocSite._method.getDefiningClass().getPackage() != null)
125
				label = allocSite._method.getDefiningClass().getPackage().getName();
126
			break;
124
			break;
127
		case AD_COL_LINE_NO:
125
		case AD_COL_LINE_NO:
128
			label = "" + allocSite._lineNo;
126
			label = String.valueOf(allocSite._lineNo);
129
			break;
127
			break;
130
		case AD_COL_TOTAL_INST:
128
		case AD_COL_TOTAL_INST:
131
			label = "" + allocSite._total;
129
			if (noperc)
130
				label = String.valueOf(allocSite._total);
131
			else
132
				label = formatPercent(allocSite._total, _allocAll._total);
132
			break;
133
			break;
133
		case AD_COL_TOTAL_SIZE:
134
		case AD_COL_TOTAL_SIZE:
134
			label = "" + allocSite._totalSize;
135
			if (noperc)
136
				label = String.valueOf(allocSite._totalSize);
137
			else
138
				label = formatPercent(allocSite._totalSize, _allocAll._totalSize);
135
			break;
139
			break;
136
		case AD_COL_LIVE_INST:
140
		case AD_COL_LIVE_INST:
137
			label = "" + (allocSite._total - allocSite._collected);
141
			if (noperc)
142
				label = String.valueOf(allocSite._total - allocSite._collected);
143
			else
144
				label = formatPercent(allocSite._total - allocSite._collected,
145
						_allocAll._total - _allocAll._collected);
138
			break;
146
			break;
139
		case AD_COL_LIVE_SIZE:
147
		case AD_COL_LIVE_SIZE:
140
			label = "" + (allocSite._totalSize - allocSite._collectedSize);
148
			if (noperc)
149
				label = String.valueOf(allocSite._totalSize - allocSite._collectedSize);
150
			else
151
				label = formatPercent(allocSite._totalSize - allocSite._collectedSize,
152
						_allocAll._totalSize - _allocAll._collectedSize);
141
			break;
153
			break;
142
		case AD_COL_AVG_AGE:
154
		case AD_COL_AVG_AGE:
143
			double age = 0;
155
			if (noperc) {
144
			if (allocSite._total > 0) {
156
				double age = 0;
145
				age = (double) allocSite._sumAges / allocSite._total;
157
				if (allocSite._total > 0) {
146
				label = "" + age;
158
					age = (double) allocSite._sumAges / allocSite._total;
159
					label = String.valueOf(age);
160
				}
161
				IContextLabelFormatProvider formatter = TIContextProvider.instance().getContextLabelFormatProvider(TIContextAttributes.CALL_SITE_AVG_AGE);
162
				label = formatter.getDisplayStringFromElement(new Double(age), null, IContextLabelFormatProvider.MODE_COLUMN_CONTENT);
163
			} else {
164
				label = formatPercent(allocSite._sumAges, _allocAll._sumAges);
147
			}
165
			}
148
			IContextLabelFormatProvider formatter = TIContextProvider.instance().getContextLabelFormatProvider(TIContextAttributes.CALL_SITE_AVG_AGE);
149
			label = formatter.getDisplayStringFromElement(new Double(age), null, IContextLabelFormatProvider.MODE_COLUMN_CONTENT);
150
			break;
166
			break;
151
		}
167
		}
168
		if (null == label)
169
			label = "";
152
		return label;
170
		return label;
153
	}
171
	}
154
172
155
	public Image getColumnImage(Object element, int columnIndex) {
173
	public Image getColumnImage(Object element, int columnIndex) {
156
		StatisticTableColumnInfo info = StatisticTableColumnInfo.getStatisticTableColumnInfo(getTree().getColumn(columnIndex));
174
		StatisticViewColumnInfo info = StatisticViewColumnInfo.getStatisticTableColumnInfo(getTree().getColumn(columnIndex));
157
		int pos = info.getColumnData().getInitalPos();
175
		int pos = info.getColumnData().getInitalPos();
158
		Image image = null;
176
		Image image = null;
159
		if (!(element instanceof AllocationSite))
177
		if (!(element instanceof AllocationSite))
160
			return image;
178
			return image;
161
		AllocationSite allocSite = (AllocationSite) element;
179
		AllocationSite allocSite = (AllocationSite) element;
180
		String name = null;
162
		switch (pos) {
181
		switch (pos) {
163
		case AD_COL_METHOD_NAME:
182
		case AD_COL_METHOD_NAME:
164
			if (allocSite._method != null) {
183
			name = allocSite.getMethodName();
184
			if (name != null) {
165
				IContextLabelFormatProvider formatter = TIContextProvider.instance().getContextLabelFormatProvider(TIContextAttributes.METHOD_NAME);
185
				IContextLabelFormatProvider formatter = TIContextProvider.instance().getContextLabelFormatProvider(TIContextAttributes.METHOD_NAME);
166
				image = formatter.getDisplayImageByElement(allocSite._method.getName(), allocSite._method, IContextLabelFormatProvider.MODE_COLUMN_CONTENT);
186
				image = formatter.getDisplayImageByElement(name, null, IContextLabelFormatProvider.MODE_COLUMN_CONTENT);
167
			}
187
			}
168
			break;
188
			break;
169
		case AD_COL_CLASS_NAME:
189
		case AD_COL_CLASS_NAME:
170
			if (allocSite._method != null &&
190
			name = allocSite.getClassName();
171
					allocSite._method.getDefiningClass() != null) {
191
			if (name != null) {
172
				TRCClass cls = allocSite._method.getDefiningClass();
173
				IContextLabelFormatProvider formatter = TIContextProvider.instance().getContextLabelFormatProvider(TIContextAttributes.CLASS_NAME);
192
				IContextLabelFormatProvider formatter = TIContextProvider.instance().getContextLabelFormatProvider(TIContextAttributes.CLASS_NAME);
174
				image = formatter.getDisplayImageByElement(cls.getName(), cls, IContextLabelFormatProvider.MODE_COLUMN_CONTENT);
193
				image = formatter.getDisplayImageByElement(name, null, IContextLabelFormatProvider.MODE_COLUMN_CONTENT);
175
			}
194
			}
176
			break;
195
			break;
177
		case AD_COL_PACKAGE_NAME:
196
		case AD_COL_PACKAGE_NAME:
178
			if (allocSite._method != null &&
197
			name = allocSite.getPackageName();
179
					allocSite._method.getDefiningClass() != null &&
198
			if (name != null) {
180
					allocSite._method.getDefiningClass().getPackage() != null) {
181
				TRCPackage pkg = allocSite._method.getDefiningClass().getPackage();
182
				IContextLabelFormatProvider formatter = TIContextProvider.instance().getContextLabelFormatProvider(TIContextAttributes.PACKAGE_NAME);
199
				IContextLabelFormatProvider formatter = TIContextProvider.instance().getContextLabelFormatProvider(TIContextAttributes.PACKAGE_NAME);
183
				image = formatter.getDisplayImageByElement(pkg.getName(), pkg, IContextLabelFormatProvider.MODE_COLUMN_CONTENT);
200
				image = formatter.getDisplayImageByElement(name, null, IContextLabelFormatProvider.MODE_COLUMN_CONTENT);
184
			}
201
			}
185
			break;
202
			break;
186
		}
203
		}
Lines 194-223 Link Here
194
		AllocationSite a1 = (AllocationSite) e1;
211
		AllocationSite a1 = (AllocationSite) e1;
195
		AllocationSite a2 = (AllocationSite) e2;
212
		AllocationSite a2 = (AllocationSite) e2;
196
		switch (pos) {
213
		switch (pos) {
197
		case AD_COL_METHOD_NAME:
198
			ret = Utils.compare(a1._method != null ? a1._method.getName() : null
199
					, a2._method != null ? a2._method.getName() : null);
200
			break;
201
		case AD_COL_CLASS_NAME:
202
			ret = Utils.compare(a1._method != null &&
203
					a1._method.getDefiningClass() != null ?
204
							a1._method.getDefiningClass().getName() : null
205
					, a2._method != null &&
206
					a2._method.getDefiningClass() != null ?
207
							a2._method.getDefiningClass().getName() : null);
208
			break;
209
		case AD_COL_PACKAGE_NAME:
214
		case AD_COL_PACKAGE_NAME:
210
			ret = Utils.compare(a1._method != null &&
215
			if (0 == ret) {
211
					a1._method.getDefiningClass() != null &&
216
				ret = Utils.compare(a1.getPackageName(), a2.getPackageName());
212
					a1._method.getDefiningClass().getPackage() != null ?
217
			}
213
							a1._method.getDefiningClass().getPackage().getName() : null
218
			//break;
214
					, a2._method != null &&
219
		case AD_COL_CLASS_NAME:
215
					a2._method.getDefiningClass() != null &&
220
			if (0 == ret) {
216
					a2._method.getDefiningClass().getPackage() != null ?
221
				ret = Utils.compare(a1.getClassName(), a2.getClassName());
217
							a2._method.getDefiningClass().getPackage().getName() : null);
222
			}
218
			break;
223
			//break;
224
		case AD_COL_METHOD_NAME:
225
			if (0 == ret) {
226
				ret = Utils.compare(a1.getMethodName(), a2.getMethodName());
227
			}
228
			//break;
219
		case AD_COL_LINE_NO:
229
		case AD_COL_LINE_NO:
220
			ret = a1._lineNo - a2._lineNo;
230
			if (0 == ret) {
231
				ret = a1._lineNo - a2._lineNo;
232
			}
221
			break;
233
			break;
222
		case AD_COL_TOTAL_INST:
234
		case AD_COL_TOTAL_INST:
223
			ret = a1._total - a2._total;
235
			ret = a1._total - a2._total;
Lines 232-240 Link Here
232
			ret = (a1._totalSize - a1._collectedSize) - (a2._totalSize - a2._collectedSize);
244
			ret = (a1._totalSize - a1._collectedSize) - (a2._totalSize - a2._collectedSize);
233
			break;
245
			break;
234
		case AD_COL_AVG_AGE:
246
		case AD_COL_AVG_AGE:
235
			double age1 = a1._total > 0 ? a1._sumAges / a1._total : 0;
247
			ret = a1._sumAges - a2._sumAges;
236
			double age2 = a2._total > 0 ? a2._sumAges / a2._total : 0;
237
			ret = Utils.compare(age1, age2);
238
			break;
248
			break;
239
		}
249
		}
240
		return ret;
250
		return ret;
Lines 266-281 Link Here
266
			_class = (TRCClass) obj;
276
			_class = (TRCClass) obj;
267
			_nextIndex = 0;
277
			_nextIndex = 0;
268
			_allocSites.clear();
278
			_allocSites.clear();
279
			_allocAll.clear();
269
			String text = Utils.getPackageClassName(_class);
280
			String text = Utils.getPackageClassName(_class);
270
			if (text.length() > 0)
281
			if (text.length() > 0)
271
				text = "Allocation details for '" + text + "'";
282
				text = "Allocation details for '" + text + "'";
272
			_label.setText(text);
283
			_label.setText(text);
273
			//_label.getParent().layout();
274
		}
284
		}
275
		refresh();
285
		refresh();
276
	}
286
	}
277
287
278
	void updateData() {
288
	void updateData() {
289
		_nextIndex = 0;
290
		_allocSites.clear();
291
		_allocAll.clear();
279
		if (null == _class)
292
		if (null == _class)
280
			return;
293
			return;
281
		TRCObjectAllocationAnnotation aa = Utils.getAllocationAnnotation(_class);
294
		TRCObjectAllocationAnnotation aa = Utils.getAllocationAnnotation(_class);
Lines 309-322 Link Here
309
			int j = i + i + 1;
322
			int j = i + i + 1;
310
			if (j < objectsLen && objects.get(j) instanceof TRCFullTraceObject) {
323
			if (j < objectsLen && objects.get(j) instanceof TRCFullTraceObject) {
311
				TRCFullTraceObject trObj = (TRCFullTraceObject) objects.get(j);
324
				TRCFullTraceObject trObj = (TRCFullTraceObject) objects.get(j);
325
				int objSize = trObj.getSize();
312
				if (trObj.getCollectTime() > 0) {
326
				if (trObj.getCollectTime() > 0) {
313
					allocSite._collected++;
327
					allocSite._collected++;
314
					allocSite._collectedSize += trObj.getSize();
328
					allocSite._collectedSize += objSize;
329
					_allocAll._collected++;
330
					_allocAll._collectedSize += objSize;
315
				}
331
				}
316
				allocSite._totalSize += trObj.getSize();
317
				int age = Utils.getObjAge(trObj, listGC);
332
				int age = Utils.getObjAge(trObj, listGC);
333
				allocSite._totalSize += objSize;
318
				allocSite._sumAges += age;
334
				allocSite._sumAges += age;
319
				allocSite._total++;
335
				allocSite._total++;
336
				_allocAll._totalSize += objSize;
337
				_allocAll._sumAges += age;
338
				_allocAll._total++;
320
			}
339
			}
321
		}
340
		}
322
		_nextIndex = lineNoLen;
341
		_nextIndex = lineNoLen;
(-)src/org/eclipse/tptp/trace/jvmti/internal/client/widgets/Utils.java (+5 lines)
Lines 514-519 Link Here
514
		return val;
514
		return val;
515
	}
515
	}
516
516
517
	static public int loadIntOption(String opt) {
518
		int val = TraceUIPlugin.getDefault().getPreferenceStore().getInt(opt);
519
		return val;
520
	}
521
517
	static public void saveIntOption(String opt, int val) {
522
	static public void saveIntOption(String opt, int val) {
518
		TraceUIPlugin.getDefault().getPreferenceStore().setValue(opt, val);
523
		TraceUIPlugin.getDefault().getPreferenceStore().setValue(opt, val);
519
	}
524
	}
(-)src/org/eclipse/tptp/trace/jvmti/internal/client/views/StatisticViewColumnInfo.java (+83 lines)
Added Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved.   This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * $Id: StatisticTableColumnInfo.java,v 1.4 2005/08/10 02:37:48 popescu Exp $
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.tptp.trace.jvmti.internal.client.views;
13
14
import org.eclipse.hyades.trace.views.util.internal.ColumnData;
15
import org.eclipse.swt.*;
16
import org.eclipse.swt.widgets.*;
17
18
/**
19
 * This class was ported from hyades project for JVMTI trace client.
20
 */
21
public class StatisticViewColumnInfo {
22
23
	private boolean _isSortColumn = false;
24
	private boolean _isDeltaColumn = false;
25
	private ColumnData _columnData;
26
27
	public ColumnData getColumnData() {
28
		return _columnData;
29
	}
30
31
	public boolean isSortColumn() {
32
		return _isSortColumn;
33
	}
34
35
	public boolean isDeltaColumn() {
36
		return _isDeltaColumn;
37
	}
38
39
	public void setSortColumn(boolean flag) {
40
		_isSortColumn = flag;
41
	}
42
43
	public void setDeltaColumn(boolean flag) {
44
		_isDeltaColumn = flag;
45
	}
46
47
	static public StatisticViewColumnInfo getStatisticTableColumnInfo(TreeColumn col) {
48
		if (col.getData() != null && col.getData() instanceof StatisticViewColumnInfo) {
49
			return (StatisticViewColumnInfo) (col.getData());
50
		} else {
51
			return null;
52
		}
53
	}
54
55
	private StatisticViewColumnInfo(BaseStatisticView statisticView, ColumnData data) {
56
		TreeColumn treeColumn = new TreeColumn(statisticView.getTree(), SWT.NULL | SWT.NO_BACKGROUND | data.getAlignment());
57
		treeColumn.setData(this);
58
		initializeTreeColumn(statisticView, treeColumn, data, true);
59
	}
60
61
	public StatisticViewColumnInfo(BaseStatisticView statisticView, ColumnData data, boolean deltaColumnsEnabled) {
62
		TreeColumn treeColumn = new TreeColumn(statisticView.getTree(), SWT.NULL | SWT.NO_BACKGROUND | data.getAlignment());
63
		treeColumn.setData(this);
64
		initializeTreeColumn(statisticView, treeColumn, data, false);
65
		if (deltaColumnsEnabled && data.supportsDelta()) {
66
			new StatisticViewColumnInfo(statisticView, data);
67
		}
68
	}
69
70
	private void initializeTreeColumn(BaseStatisticView statisticView, TreeColumn treeColumn, ColumnData data, boolean isDeltaColumn) {
71
		_columnData = data;
72
		_isDeltaColumn = isDeltaColumn;
73
		treeColumn.setResizable(data.isResizable());
74
		if (isDeltaColumn) {
75
			treeColumn.setText(UIMessages._Delta + ":" + data.name());
76
		} else {
77
			treeColumn.setText(data.name());
78
		}
79
		treeColumn.setWidth(data.width());
80
		treeColumn.addSelectionListener(statisticView);
81
		treeColumn.addControlListener(statisticView);
82
	}
83
}

Return to bug 167995