Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[linuxtools-dev] Using the Time Graph Viewer and contributing to the project

Hi everyone,

My name is Generoso Pagano and I am currently working as R&D Engineer at 
Inria, a French research institute.
In my team, we are working on a generic and open infrastructure for trace
management and analysis, called FrameSoC [1,2].

For the Gantt chart view of our infrastructure, I want to use your Time 
Graph Viewer, since it has good performance and fits our needs.

I am also interested in making some contribution to your viewer, 
possibly introducing some functionalities currently missing.
I list some of the ideas I have in mind:

(1) The possibility to add a "drag" time-interval selection-change listener,
    to be notified of the interval selection change in the gantt, while it is 
    happening.
    --> I have already written the code for this (attached patch).

(2) Improve the view filter dialog, introducing a text field to easily find
    the elements of interest in the tree.

(3) Introduce the vertical zoom in the viewer.
   
I would like to have some feedback about these ideas (Do you have plans on these
topics? Do you have hints or suggestions?).
Furthermore, I'd appreciate any advice about contributing to the project.

Best Regards,

Generoso Pagano

[1] Generoso Pagano et al. "Trace Management and Analysis for Embedded Systems". 
Proceedings of the IEEEļ¼—th International Symposium on Embedded Multicore SoCs 
(MCSoC-13), Tokyo, Japan, Dec 2013.	

[2] Generoso Pagano et al. "The FrameSoC Software Architecture for Multiple-View 
Trace Data Analysis". In Proceedings of the 2014 ACM SIGCHI symposium on 
Engineering interactive computing systems (EICS '14), ACM, Rome, June 2014.
From 2af897aa59b437df8c56fa980539a62c691e5b5e Mon Sep 17 00:00:00 2001
From: Generoso Pagano <generoso.pagano@xxxxxxxx>
Date: Thu, 10 Jul 2014 12:39:08 +0200
Subject: [PATCH] Added drag selection listener support to the Time Graph
 Viewer

---
 .../timegraph/ITimeGraphDragSelectionListener.java | 30 ++++++++++
 .../timegraph/TimeGraphDragSelectionEvent.java     | 68 ++++++++++++++++++++++
 .../timegraph/widgets/TimeGraphControl.java        | 62 ++++++++++++++++++++
 3 files changed, 160 insertions(+)
 create mode 100644 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITimeGraphDragSelectionListener.java
 create mode 100644 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphDragSelectionEvent.java

diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITimeGraphDragSelectionListener.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITimeGraphDragSelectionListener.java
new file mode 100644
index 0000000..c76054f
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITimeGraphDragSelectionListener.java
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * Copyright (c) 2014 Inria
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Generoso Pagano, Inria - Initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
+
+import java.util.EventListener;
+
+/**
+ * A listener which is notified when a timegraph changes its selected
+ * time interval during a mouse drag operation.
+ *
+ * @author Generoso Pagano
+ */
+public interface ITimeGraphDragSelectionListener extends EventListener {
+
+    /**
+     * Notifies that the timegraph selected time interval changed.
+     *
+     * @param event event object describing details
+     */
+    void dragSelectionChanged(TimeGraphDragSelectionEvent event);
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphDragSelectionEvent.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphDragSelectionEvent.java
new file mode 100644
index 0000000..4fc628e
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphDragSelectionEvent.java
@@ -0,0 +1,68 @@
+/*****************************************************************************
+ * Copyright (c) 2014 Inria
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Generoso Pagano, Inria - Initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
+
+import java.util.EventObject;
+
+/**
+ * Notifier for the time graph that a new time interval has been selected.
+ *
+ * @author Generoso Pagano
+ */
+public class TimeGraphDragSelectionEvent extends EventObject {
+
+    /**
+     * Default serial version UID for this class.
+     */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * Start timestamp of the selected time interval.
+     */
+    private final long fStart;
+
+    /**
+     * End timestamp of the selected time interval.
+     */
+    private final long fEnd;
+
+    /**
+     * Standard constructor
+     *
+     * @param source
+     *            The source of this event
+     * @param start
+     *            The start timestamp of the selected time interval.
+     * @param end
+     *            The end timestamp of the selected time interval.
+     */
+    public TimeGraphDragSelectionEvent(Object source, long start, long end) {
+        super(source);
+        fStart = start;
+        fEnd = end;
+    }
+
+    /**
+     * @return the start timestamp of the selected time interval
+     */
+    public long getStart() {
+        return fStart;
+    }
+
+    /**
+     * @return the selected entry or null if the selection is empty.
+     */
+    public long getEnd() {
+        return fEnd;
+    }
+
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java
index a2bf16d..5b12e65 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeGraphControl.java
@@ -15,6 +15,7 @@
  *                            provide base classes for time graph view
  *                            Add display of links between items
  *   Xavier Raynaud, Kalray - Code optimization
+ *   Generoso Pagano, Inria - Support for drag selection listener
  *****************************************************************************/
 
 package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;
@@ -38,10 +39,12 @@ import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.timestamp.TmfNanoTimestamp;
 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestampDelta;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphColorListener;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphDragSelectionListener;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider2;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeGraphTreeListener;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.StateItem;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphDragSelectionEvent;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TimeGraphTreeExpansionEvent;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ILinkEvent;
 import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;
@@ -139,6 +142,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
     private ITimeGraphPresentationProvider fTimeGraphProvider = null;
     private ItemData fItemData = null;
     private List<SelectionListener> fSelectionListeners;
+    private List<ITimeGraphDragSelectionListener> fDragSelectionListeners;
     private final List<ISelectionChangedListener> fSelectionChangedListeners = new ArrayList<>();
     private final List<ITimeGraphTreeListener> fTreeListeners = new ArrayList<>();
     private final List<MenuDetectListener> fTimeGraphEntryMenuListeners = new ArrayList<>();
@@ -334,6 +338,34 @@ public class TimeGraphControl extends TimeGraphBaseControl
     }
 
     /**
+     * Add a drag selection listener
+     *
+     * @param listener
+     *            The listener to add
+     */
+    public void addDragSelectionListener(ITimeGraphDragSelectionListener listener) {
+        if (listener == null) {
+            SWT.error(SWT.ERROR_NULL_ARGUMENT);
+        }
+        if (null == fDragSelectionListeners) {
+            fDragSelectionListeners = new ArrayList<>();
+        }
+        fDragSelectionListeners.add(listener);
+    }
+
+    /**
+     * Remove a drag selection listener
+     *
+     * @param listener
+     *            The listener to remove
+     */
+    public void removeDragSelectionListener(ITimeGraphDragSelectionListener listener) {
+        if (null != fDragSelectionListeners) {
+            fDragSelectionListeners.remove(listener);
+        }
+    }
+
+    /**
      * Selection changed callback
      */
     public void fireSelectionChanged() {
@@ -360,6 +392,35 @@ public class TimeGraphControl extends TimeGraphBaseControl
     }
 
     /**
+     * Drag Selection changed callback
+     *
+     * @param start
+     *            Time interval start
+     * @param end
+     *            Time interval end
+     */
+    public void fireDragSelectionChanged(long start, long end) {
+        // check for backward intervals
+        long rEnd, rStart;
+        if (start>end) {
+            rEnd = start;
+            rStart = end;
+        } else {
+            rEnd = end;
+            rStart = start;
+        }
+        // call the listeners
+        if (null != fDragSelectionListeners) {
+            Iterator<ITimeGraphDragSelectionListener> it = fDragSelectionListeners.iterator();
+            while (it.hasNext()) {
+                ITimeGraphDragSelectionListener listener = it.next();
+                listener.dragSelectionChanged(new TimeGraphDragSelectionEvent(this, rStart, rEnd));
+            }
+        }
+    }
+
+
+    /**
      * Get the traces in the model
      *
      * @return The array of traces
@@ -2011,6 +2072,7 @@ public class TimeGraphControl extends TimeGraphBaseControl
             fDragX = Math.min(Math.max(e.x, fTimeProvider.getNameSpace()), size.x - RIGHT_MARGIN);
             redraw();
             fTimeGraphScale.setDragRange(fDragX0, fDragX);
+            fireDragSelectionChanged(getTimeAtX(fDragX0), getTimeAtX(fDragX));
         } else if (DRAG_ZOOM == fDragState) {
             fDragX = Math.min(Math.max(e.x, fTimeProvider.getNameSpace()), size.x - RIGHT_MARGIN);
             redraw();
-- 
1.7.11.7


Back to the top