1 /*******************************************************************************
2 * Copyright (c) 2013 École Polytechnique de Montréal
4 * All rights reserved. This program and the accompanying materials are made
5 * available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Geneviève Bastien - Initial implementation and API
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.synchronization
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalHandler
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceSynchronizedSignal
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.synchronization
.SynchronizationAlgorithm
;
20 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.TmfView
;
21 import org
.eclipse
.swt
.SWT
;
22 import org
.eclipse
.swt
.widgets
.Composite
;
23 import org
.eclipse
.swt
.widgets
.Display
;
24 import org
.eclipse
.swt
.widgets
.Tree
;
25 import org
.eclipse
.swt
.widgets
.TreeColumn
;
26 import org
.eclipse
.swt
.widgets
.TreeItem
;
29 * Small view to display statistics about a synchronization
31 * @author Geneviève Bastien
34 public class TmfSynchronizationView
extends TmfView
{
37 * The ID corresponds to the package in which this class is embedded.
39 public static final String ID
= "org.eclipse.linuxtools.tmf.ui.views.synchronization"; //$NON-NLS-1$
44 public static final String TMF_SYNCHRONIZATION_VIEW
= "SynchronizationView"; //$NON-NLS-1$
47 * The synchronization algorithm to display stats for
49 private SynchronizationAlgorithm fAlgoSync
;
56 public TmfSynchronizationView() {
57 super(TMF_SYNCHRONIZATION_VIEW
);
61 public void createPartControl(Composite parent
) {
62 fTree
= new Tree(parent
, SWT
.NONE
);
63 TreeColumn nameCol
= new TreeColumn(fTree
, SWT
.NONE
, 0);
64 TreeColumn valueCol
= new TreeColumn(fTree
, SWT
.NONE
, 1);
65 nameCol
.setText(Messages
.TmfSynchronizationView_NameColumn
);
66 valueCol
.setText(Messages
.TmfSynchronizationView_ValueColumn
);
68 fTree
.setItemCount(0);
70 fTree
.setHeaderVisible(true);
76 private void updateTable() {
77 fTree
.setItemCount(0);
78 if (fAlgoSync
== null) {
82 for (Map
.Entry
<String
, Map
<String
, Object
>> entry
: fAlgoSync
.getStats().entrySet()) {
83 TreeItem item
= new TreeItem(fTree
, SWT
.NONE
);
84 item
.setText(0, entry
.getKey().toString());
85 item
.setText(1, entry
.getValue().toString());
87 for (Map
.Entry
<String
, Object
> subentry
: entry
.getValue().entrySet()) {
88 TreeItem subitem
= new TreeItem(item
, SWT
.NONE
);
89 subitem
.setText(0, subentry
.getKey().toString());
90 subitem
.setText(1, subentry
.getValue().toString());
94 /* Expand the tree items */
95 for (int i
= 0; i
< fTree
.getItemCount(); i
++) {
96 fTree
.getItem(i
).setExpanded(true);
99 for (TreeColumn column
: fTree
.getColumns()) {
105 public void setFocus() {
110 * Handler called when traces are synchronized
113 * Contains the information about the selection.
116 public void traceSynchronized(TmfTraceSynchronizedSignal signal
) {
117 if (signal
.getSyncAlgo() != fAlgoSync
) {
118 fAlgoSync
= signal
.getSyncAlgo();
119 Display
.getDefault().asyncExec(new Runnable() {