|
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 |
} |