summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorBernd Hufmann2012-11-20 11:52:27 (EST)
committer Bernd Hufmann2012-11-21 14:01:42 (EST)
commit99a0f482a753dddd3d8f4b92d81eb1af479bea04 (patch)
treeab98fd2e1dc0536ae56392eddad3d3bab2e95a0a
parent8d58ce2853847af17008ee8e02cb7f941bd42fee (diff)
downloadorg.eclipse.linuxtools-99a0f482a753dddd3d8f4b92d81eb1af479bea04.zip
org.eclipse.linuxtools-99a0f482a753dddd3d8f4b92d81eb1af479bea04.tar.gz
org.eclipse.linuxtools-99a0f482a753dddd3d8f4b92d81eb1af479bea04.tar.bz2
Update TMF Environment view to use tree with columnsrefs/changes/57/8757/5
The new implementation uses a tree to group environment variables per CTF trace (instead of one flat list). This improves the readability of this view. Change-Id: I4784adf32bc88360cec68c54f688000b251e08aa Reviewed-on: https://git.eclipse.org/r/8757 Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com> IP-Clean: Patrick Tasse <patrick.tasse@gmail.com> Tested-by: Hudson CI
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/environment/TmfEnvironmentView.java58
1 files changed, 26 insertions, 32 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/environment/TmfEnvironmentView.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/environment/TmfEnvironmentView.java
index 921662d..a35a7e4 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/environment/TmfEnvironmentView.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/environment/TmfEnvironmentView.java
@@ -8,11 +8,10 @@
*
* Contributors:
* Matthew Khouzam - Initial API and implementation
+ * Bernd Hufmann - Updated to use Tree with columns to be able to group traces
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.views.environment;
-import java.util.ArrayList;
-
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceClosedSignal;
@@ -23,15 +22,15 @@ import org.eclipse.linuxtools.tmf.ui.editors.ITmfTraceEditor;
import org.eclipse.linuxtools.tmf.ui.views.TmfView;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IEditorPart;
/**
* Displays the CTF trace properties.
*
- * @version 1.0
+ * @version 1.1
* @author Matthew Khouzam
*/
public class TmfEnvironmentView extends TmfView {
@@ -40,7 +39,7 @@ public class TmfEnvironmentView extends TmfView {
public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.environment"; //$NON-NLS-1$
private ITmfTrace fTrace;
- private Table fTable;
+ private Tree fTree;
/**
* Default constructor
@@ -53,26 +52,18 @@ public class TmfEnvironmentView extends TmfView {
// ------------------------------------------------------------------------
// ViewPart
// ------------------------------------------------------------------------
- final private class Pair{
- final private String key;
- final private String value;
- public Pair(String k) { key = k ; value = "";} //$NON-NLS-1$
- public Pair(String k, String v){ key = k; value = v; }
- public String getKey() { return key; }
- public String getValue() { return value; }
- }
@Override
public void createPartControl(Composite parent) {
- fTable = new Table(parent, SWT.NONE);
- TableColumn nameCol = new TableColumn(fTable, SWT.NONE, 0);
- TableColumn valueCol = new TableColumn(fTable, SWT.NONE, 1);
+ fTree = new Tree(parent, SWT.NONE);
+ TreeColumn nameCol = new TreeColumn(fTree, SWT.NONE, 0);
+ TreeColumn valueCol = new TreeColumn(fTree, SWT.NONE, 1);
nameCol.setText("Environment Variable"); //$NON-NLS-1$
valueCol.setText("Value"); //$NON-NLS-1$
- fTable.setItemCount(0);
+ fTree.setItemCount(0);
- fTable.setHeaderVisible(true);
+ fTree.setHeaderVisible(true);
nameCol.pack();
valueCol.pack();
@@ -86,10 +77,11 @@ public class TmfEnvironmentView extends TmfView {
}
private void updateTable() {
- fTable.setItemCount(0);
+ fTree.setItemCount(0);
if (fTrace == null) {
return;
}
+
ITmfTrace[] traces;
if (fTrace instanceof TmfExperiment) {
TmfExperiment experiment = (TmfExperiment) fTrace;
@@ -97,25 +89,26 @@ public class TmfEnvironmentView extends TmfView {
} else {
traces = new ITmfTrace[] { fTrace };
}
- ArrayList<Pair> tableData = new ArrayList<Pair>();
+
for (ITmfTrace trace : traces) {
- Pair traceEntry = new Pair(trace.getName());
- tableData.add(traceEntry);
if (trace instanceof CtfTmfTrace) {
+ TreeItem item = new TreeItem(fTree, SWT.NONE);
+ item.setText(0, trace.getName());
CtfTmfTrace ctfTrace = (CtfTmfTrace) trace;
for (String varName : ctfTrace.getEnvNames()) {
- tableData.add(new Pair(varName, ctfTrace.getEnvValue(varName)));
+ TreeItem subItem = new TreeItem(item, SWT.NONE);
+ subItem.setText(0, varName);
+ subItem.setText(1, ctfTrace.getEnvValue(varName));
}
}
}
- for (Pair pair : tableData) {
- TableItem item = new TableItem(fTable, SWT.NONE);
- item.setText(0, pair.getKey());
- item.setText(1, pair.getValue());
+ // Expand the tree items
+ for (int i = 0; i < fTree.getItemCount(); i++) {
+ fTree.getItem(i).setExpanded(true);
}
- for (TableColumn column : fTable.getColumns()) {
+ for (TreeColumn column : fTree.getColumns()) {
column.pack();
}
}
@@ -125,7 +118,7 @@ public class TmfEnvironmentView extends TmfView {
*/
@Override
public void setFocus() {
- fTable.setFocus();
+ fTree.setFocus();
}
/**
@@ -155,8 +148,9 @@ public class TmfEnvironmentView extends TmfView {
public void traceClosed(TmfTraceClosedSignal signal) {
if (signal.getTrace() == fTrace) {
fTrace = null;
- fTable.setItemCount(0);
+ fTree.setItemCount(0);
}
}
}
+