aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Khouzam2012-04-12 11:45:12 (EDT)
committerFrancois Chouinard2012-04-16 14:20:37 (EDT)
commite01715736570787024910bdb3cf25dfa30ae4469 (patch)
tree3f619b5265ba3ddd0cf1300f29e8c5d4e54acd5c
parent8c5b11f630b587e89547a612f62f9effd6d85eb1 (diff)
downloadorg.eclipse.linuxtools-e01715736570787024910bdb3cf25dfa30ae4469.zip
org.eclipse.linuxtools-e01715736570787024910bdb3cf25dfa30ae4469.tar.gz
org.eclipse.linuxtools-e01715736570787024910bdb3cf25dfa30ae4469.tar.bz2
Add environment variables view widget
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF1
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/plugin.properties1
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/plugin.xml9
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/environment/TmfEnvironmentView.java126
4 files changed, 137 insertions, 0 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF b/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
index 159a30a..26f1550 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
@@ -32,6 +32,7 @@ Export-Package: org.eclipse.linuxtools.internal.tmf.ui;x-friends:="org.eclipse.l
org.eclipse.linuxtools.tmf.ui.views.colors,
org.eclipse.linuxtools.tmf.ui.views.distribution.model,
org.eclipse.linuxtools.tmf.ui.views.events,
+ org.eclipse.linuxtools.tmf.ui.views.environment,
org.eclipse.linuxtools.tmf.ui.views.filter,
org.eclipse.linuxtools.tmf.ui.views.histogram,
org.eclipse.linuxtools.tmf.ui.views.statistics,
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/plugin.properties b/lttng/org.eclipse.linuxtools.tmf.ui/plugin.properties
index caf71c6..e92ae2d 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/plugin.properties
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/plugin.properties
@@ -15,6 +15,7 @@ events.editor.name = Events Editor
eventsview.editor.name = Events View
uml2sd.view.name = Sequence Diagram
histogram.view.name = Histogram
+environment.view.name = Environment Variables
wizard.category.name = Tracing
project.new.wizard.name = Tracing Project
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/plugin.xml b/lttng/org.eclipse.linuxtools.tmf.ui/plugin.xml
index 61e9b6b..9d66f8c 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/plugin.xml
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/plugin.xml
@@ -35,6 +35,15 @@
id="org.eclipse.linuxtools.tmf.ui.views.timechart"
name="%timechart.view.name"
restorable="true">
+ </view>
+ <view
+ allowMultiple="false"
+ category="org.eclipse.linuxtools.tmf.ui.views.category"
+ class="org.eclipse.linuxtools.tmf.ui.views.environment.TmfEnvironmentView"
+ icon="icons/eview16/events_view.gif"
+ id="org.eclipse.linuxtools.tmf.ui.views.environment"
+ name="%environment.view.name"
+ restorable="true">
</view>
<view
allowMultiple="false"
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
new file mode 100644
index 0000000..5c3e43a
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/environment/TmfEnvironmentView.java
@@ -0,0 +1,126 @@
+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.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.core.experiment.TmfExperiment;
+import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+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;
+
+public class TmfEnvironmentView extends TmfView {
+
+ public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.environment"; //$NON-NLS-1$
+ private TmfExperiment<?> fExperiment;
+ private Table fTable;
+ final private String fTitlePrefix;
+ private Composite fParent;
+
+ public TmfEnvironmentView() {
+ super("EnvironmentVariables"); //$NON-NLS-1$
+ fTitlePrefix = getTitle();
+ }
+
+ // ------------------------------------------------------------------------
+ // 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
+ @SuppressWarnings("unchecked")
+ public void createPartControl(Composite parent) {
+ fParent = parent;
+ TableItem ti[];
+ // If an experiment is already selected, update the table
+ TmfExperiment<ITmfEvent> experiment = (TmfExperiment<ITmfEvent>) TmfExperiment
+ .getCurrentExperiment();
+ if (experiment == null) {
+ return;
+ }
+ fTable = new Table(parent, SWT.BORDER|SWT.FILL);
+
+
+ ArrayList<Pair> tableData = new ArrayList<Pair>();
+ for (ITmfTrace trace : experiment.getTraces()) {
+ Pair traceEntry = new Pair(trace.getName());
+ tableData.add(traceEntry);
+ if (trace instanceof CtfTmfTrace) {
+ CtfTmfTrace ctfTrace = (CtfTmfTrace) trace;
+ for (String varName : ctfTrace
+ .getEnvNames()) {
+ tableData.add(new Pair( varName, ctfTrace.getEnvValue(varName)));
+ }
+ }
+ }
+ TableColumn nameCol = new TableColumn(fTable, SWT.NONE, 0);
+ TableColumn valueCol = new TableColumn(fTable, SWT.NONE, 1);
+ nameCol.setText("Environment Variable"); //$NON-NLS-1$
+ valueCol.setText("Value"); //$NON-NLS-1$
+
+ final int tableSize = tableData.size();
+
+ fTable.setItemCount(tableSize);
+ ti = fTable.getItems();
+ for(int i = 0; i < tableSize; i++){
+ final Pair currentPair = tableData.get(i);
+ ti[i].setText(0, currentPair.getKey());
+ ti[i].setText(1, currentPair.getValue());
+ }
+
+ fTable.setHeaderVisible(true);
+ nameCol.pack();
+ valueCol.pack();
+ fTable.pack();
+
+ parent.layout();
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
+ */
+ @Override
+ public void setFocus() {
+ fTable.setFocus();
+ }
+
+ @Override
+ public void dispose() {
+ if (fTable != null) {
+ fTable.dispose();
+ }
+ super.dispose();
+ }
+
+ @SuppressWarnings("unchecked")
+ @TmfSignalHandler
+ public void experimentSelected(TmfExperimentSelectedSignal<TmfEvent> signal) {
+ // Update the trace reference
+ TmfExperiment<TmfEvent> exp = (TmfExperiment<TmfEvent>) signal.getExperiment();
+ if (!exp.equals(fExperiment)) {
+ fExperiment = exp;
+ if (fTable != null) {
+ fTable.dispose();
+ }
+ createPartControl( fParent );
+ fParent.layout();
+ }
+ }
+
+
+}