Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 178665 Details for
Bug 325016
[TMF] Implementation of Time Chart view
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proposed patch in org.eclipse.linuxtools.tmf.ui package
org.eclipse.linuxtools.tmf.ui-timechart.patch (text/plain), 62.94 KB, created by
Patrick Tasse
on 2010-09-10 17:30:25 EDT
(
hide
)
Description:
Proposed patch in org.eclipse.linuxtools.tmf.ui package
Filename:
MIME Type:
Creator:
Patrick Tasse
Created:
2010-09-10 17:30:25 EDT
Size:
62.94 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.linuxtools.tmf.ui >Index: META-INF/MANIFEST.MF >=================================================================== >--- META-INF/MANIFEST.MF (revision 25468) >+++ META-INF/MANIFEST.MF (working copy) >@@ -23,5 +23,6 @@ > org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets, > org.eclipse.linuxtools.tmf.ui.views, > org.eclipse.linuxtools.tmf.ui.views.project, >+ org.eclipse.linuxtools.tmf.ui.views.timechart, > org.eclipse.linuxtools.tmf.ui.widgets > Bundle-Localization: plugin >Index: src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeAnalysisProvider.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeAnalysisProvider.java (revision 25468) >+++ src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeAnalysisProvider.java (working copy) >@@ -274,6 +274,8 @@ > if (threadClass != null && threadClass.length() > 0) { > name += " [" + threadClass + "]"; > } >+ /* >+ * Check if this is still necessary! > if (inclState) { > List<TimeEvent> list = trace.getTraceEvents(); > if (null != list && list.size() > 0) { >@@ -281,6 +283,7 @@ > name += " (" + getEventName(event, false, true) + ")"; > } > } >+ */ > return name; > } > >Index: src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeAnalysisViewer.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeAnalysisViewer.java (revision 25468) >+++ src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeAnalysisViewer.java (working copy) >@@ -107,7 +107,7 @@ > // called from the display order in the API > public void modelUpdate(ITmfTimeAnalysisEntry[] traces) { > if (null != _stateCtrl) { >- loadOptions(); >+ //loadOptions(); > updateInternalData(traces); > _stateCtrl.redraw(); > _timeScaleCtrl.redraw(); >@@ -118,7 +118,7 @@ > public void modelUpdate(ITmfTimeAnalysisEntry[] traces, long start, > long end, boolean updateTimeBounds) { > if (null != _stateCtrl) { >- loadOptions(); >+ //loadOptions(); > updateInternalData(traces, start, end); > if (updateTimeBounds) { > _timeRangeFixed = true; >@@ -236,6 +236,8 @@ > _endTime = entry.getStopTime(); > } > } >+ /* >+ * This is not needed if entry startTime and stopTime are properly set! > List<TimeEvent> list = entry.getTraceEvents(); > int len = list.size(); > if (len > 0) { >@@ -249,6 +251,7 @@ > _endTime = eventEndTime; > } > } >+ */ > } > > if (_beginTime < 0) >@@ -764,6 +767,12 @@ > } > } > >+ public void setMinimumItemWidth(int width) { >+ if (_stateCtrl != null) { >+ _stateCtrl.setMinimumItemWidth(width); >+ } >+ } >+ > public boolean isVisibleVerticalScroll() { > if (_stateCtrl != null) { > _stateCtrl.isVisibleVerticalScroll(); >Index: src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/model/TimeEvent.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/model/TimeEvent.java (revision 25468) >+++ src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/model/TimeEvent.java (working copy) >@@ -14,17 +14,17 @@ > > public abstract class TimeEvent implements ITimeEvent { > /* (non-Javadoc) >- * @see org.eclipse.linuxtools.tlf.widgets.timeAnalysis.model.TmTaEventI#getTrace() >+ * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent#getTrace() > */ > public abstract ITmfTimeAnalysisEntry getEntry(); > > /* (non-Javadoc) >- * @see org.eclipse.linuxtools.tlf.widgets.timeAnalysis.model.TmTaEventI#getTime() >+ * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent#getTime() > */ > public abstract long getTime(); > > /* (non-Javadoc) >- * @see org.eclipse.linuxtools.tlf.widgets.timeAnalysis.model.TmTaEventI#getDuration() >+ * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent#getDuration() > */ > public long getDuration() { > return -1; >Index: src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/model/ITmfTimeAnalysisEntry.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/model/ITmfTimeAnalysisEntry.java (revision 25468) >+++ src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/model/ITmfTimeAnalysisEntry.java (working copy) >@@ -12,6 +12,7 @@ > > package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model; > >+import java.util.Iterator; > import java.util.Vector; > > public interface ITmfTimeAnalysisEntry { >@@ -26,5 +27,27 @@ > > public long getStopTime(); > >- public <T extends ITimeEvent> Vector<T> getTraceEvents(); >+ /** >+ * Get a vector containing all events >+ * @deprecated replaced by {@link #getTraceEventsIterator()} >+ */ >+ @Deprecated public <T extends ITimeEvent> Vector<T> getTraceEvents(); >+ >+ /** >+ * Get an iterator which returns all events >+ */ >+ public <T extends ITimeEvent> Iterator<T> getTraceEventsIterator(); >+ >+ /** >+ * Get an iterator which only returns events that fall within the start time and the stop time. >+ * The visible duration is the event duration below which further detail is not discernible. >+ * If no such iterator is implemented, provide a basic iterator which returns all events. >+ * >+ * @param startTime start time in nanoseconds >+ * @param stopTime stop time in nanoseconds >+ * @param visibleDuration duration of one pixel in nanoseconds >+ */ >+ public <T extends ITimeEvent> Iterator<T> getTraceEventsIterator(long startTime, long stopTime, long visibleDuration); >+ >+ public <T extends ITimeEvent> void addTraceEvent(T event); > } >Index: src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/messages.properties >=================================================================== >--- src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/messages.properties (revision 25468) >+++ src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/messages.properties (working copy) >@@ -14,9 +14,9 @@ > TRACE_STATES_TITLE = States Transition Visualizer > > # labels >-_TRACE_ID = Process Id >+_TRACE_ID = Trace Id > _TRACE_DATE = Date >-_TRACE_NAME = Process Name >+_TRACE_NAME = Trace Name > _TRACE_CLASS_NAME = Class Name > _TRACE_GROUP_NAME = Group Name > _TRACE_START_TIME = Start Time >@@ -24,16 +24,16 @@ > _TRACE_STOP_TIME = Stop Time > _DURATION = Duration > _TRACE_STATE = State >-_NUMBER_OF_TRACES = Number of processes >-_TRACE_FILTER = Process Filter >+_NUMBER_OF_TRACES = Number of traces >+_TRACE_FILTER = Trace Filter > _TRACE_FILTER_DESC = Define the filter set > _Timescale = Time scale > _UNDEFINED_GROUP = <undefined> >-_TRACE_GROUP_LABEL = Process Group [{0}] >+_TRACE_GROUP_LABEL = Trace Group [{0}] > _EDIT_PROFILING_OPTIONS = Edit Profiling Options > > #Monitor statistics view messages > # MEM_ALLOCATION_DETAILS_FOR = Allocation details for > _LEGEND = Legend >-_TRACE_STATES = Process states >-_WINDOW_TITLE = Process Visualizer's Legend >+_TRACE_STATES = Trace states >+_WINDOW_TITLE = Trace Visualizer's Legend >Index: src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITimeAnalysisViewer.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITimeAnalysisViewer.java (revision 25468) >+++ src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITimeAnalysisViewer.java (working copy) >@@ -126,6 +126,8 @@ > > public void setItemHeight(int rowHeight); > >+ public void setMinimumItemWidth(int width); >+ > public void resizeControls(); > > public void setSelectedTrace(ITmfTimeAnalysisEntry trace); >Index: src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TmfTimeStatesCtrl.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TmfTimeStatesCtrl.java (revision 25468) >+++ src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TmfTimeStatesCtrl.java (working copy) >@@ -67,7 +67,11 @@ > ControlListener, SelectionListener, MouseTrackListener, > TraverseListener, ISelectionProvider { > >- public static final boolean DEFAULT_DRAW_THREAD_JOIN = true; >+ private static final int DRAG_NONE = 0; >+ private static final int DRAG_TRACE_ITEM = 1; >+ private static final int DRAG_GROUP_ITEM = 2; >+ private static final int DRAG_SPLIT_LINE = 3; >+ public static final boolean DEFAULT_DRAW_THREAD_JOIN = true; > public static final boolean DEFAULT_DRAW_THREAD_WAIT = true; > public static final boolean DEFAULT_DRAW_THREAD_RELEASE = true; > public static int H_SCROLLBAR_MAX = Integer.MAX_VALUE - 1; >@@ -81,8 +85,9 @@ > private boolean _mouseHover = false; > private int _itemHeightDefault = 19; > private int _itemHeight = _itemHeightDefault; >+ private int _minimumItemWidth = 0; > private int _topItem = 0; >- private int _dragState = 0; >+ private int _dragState = DRAG_NONE; > private int _hitIdx = 0; > private int _dragX0 = 0; > private int _dragX = 0; >@@ -137,13 +142,6 @@ > if (scrollHor != null) { > scrollHor.addSelectionListener(this); > } >- mouseScrollFilterListener = new Listener() { >- // This filter is used to prevent scrolling of the view when the >- // mouse wheel is used to zoom >- public void handleEvent(Event event) { >- event.doit = false; >- } >- }; > > _dragCursor3 = new Cursor(super.getDisplay(), SWT.CURSOR_SIZEWE); > _WaitCursor = new Cursor(super.getDisplay(), SWT.CURSOR_WAIT); >@@ -455,7 +453,7 @@ > if (zoomIn) { > newInterval = Math.max(Math.round((double) interval * 0.8), _timeProvider.getMinTimeInterval()); > } else { >- newInterval = Math.round((double) interval * 1.25); >+ newInterval = (long) Math.ceil((double) interval * 1.25); > } > long center = time0 + Math.round(((double) (xPos - nameSpace) / timeSpace * interval)); > long newTime0 = center - Math.round((double) newInterval * (center - time0) / interval); >@@ -631,7 +629,7 @@ > return idx >= 0 ? (Item) _data._items[idx] : null; > } > >- long hitTimeTest(int x, int y) { >+ long hitTimeTest(int x) { > if (null == _timeProvider) > return -1; > long hitTime = -1; >@@ -653,25 +651,32 @@ > } > > void selectItem(int idx, boolean addSelection) { >+ boolean changed = false; > if (addSelection) { > if (idx >= 0 && idx < _data._items.length) { > Item item = (Item) _data._items[idx]; >+ changed = (item._selected == false); > item._selected = true; > } > } else { > for (int i = 0; i < _data._items.length; i++) { > Item item = (Item) _data._items[i]; >+ if (i == idx && item._selected == false) { >+ changed = true; >+ } > item._selected = i == idx; > } > } >- boolean changed = ensureVisibleItem(idx, true); >- if (!changed) >+ changed |= ensureVisibleItem(idx, true); >+ if (changed) > redraw(); > } > > public void selectItem(ITmfTimeAnalysisEntry trace, boolean addSelection) { > Integer idx = _data.findTraceItemIndex(trace); >- selectItem(idx, addSelection); >+ if (idx != null) { >+ selectItem(idx, addSelection); >+ } > } > > public int countPerPage() { >@@ -958,12 +963,18 @@ > if (drawTracesInteraction) > drawTraceInteractions(bound, e.gc); > >+ // draw empty name space background >+ if (_itemHeight * items.length < bound.height) { >+ gc.setBackground(_colors.getBkColor(false, false, true)); >+ drawBackground(gc, bound.x, _itemHeight * items.length, nameWidth, bound.height - _itemHeight * items.length); >+ } >+ > // draw drag line, no line if name space is 0. >- if (3 == _dragState) { >+ if (DRAG_SPLIT_LINE == _dragState) { > gc.setForeground(_colors.getColor(TraceColorScheme.BLACK)); > gc.drawLine(bound.x + nameWidth, bound.y, bound.x + nameWidth, > bound.y + bound.height - 1); >- } else if (0 == _dragState && _mouseHover >+ } else if (DRAG_NONE == _dragState && _mouseHover > && _timeProvider.getNameSpace() > 0) { > gc.setForeground(_colors.getColor(TraceColorScheme.RED)); > gc.drawLine(bound.x + nameWidth, bound.y, bound.x + nameWidth, >@@ -1090,12 +1101,10 @@ > ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace; > > int x0 = rect.x; >- List<TimeEvent> list = trace.getTraceEvents(); >- // Iterator it = list.iterator(); >- int count = list.size(); >+ Iterator<ITimeEvent> iterator = trace.getTraceEventsIterator(); > ITimeEvent lastEvent = null; >- if (count > 0) { >- ITimeEvent currEvent = list.get(0); >+ if (iterator.hasNext()) { >+ ITimeEvent currEvent = iterator.next(); > ITimeEvent nextEvent = null; > long currEventTime = currEvent.getTime(); > long nextEventTime = currEventTime; >@@ -1113,8 +1122,8 @@ > while (x0 <= xEnd && null != currEvent) { > boolean stopped = false;// currEvent instanceof > // TsfTmTraceDeadEvent; >- if (idx < count) { >- nextEvent = list.get(idx); >+ if (iterator.hasNext()) { >+ nextEvent = iterator.next(); > nextEventTime = nextEvent.getTime(); > idx++; > } else if (stopped) { >@@ -1236,13 +1245,11 @@ > ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace; > > double x0 = rect.x; >- List<TimeEvent> list = trace.getTraceEvents(); >- // Iterator it = list.iterator(); >- int count = list.size(); >+ Iterator<ITimeEvent> iterator = trace.getTraceEventsIterator(); > ITimeEvent lastEvent = null; > // Trace.debug("count is: " + count); >- if (count > 0) { >- ITimeEvent currEvent = list.get(0); >+ if (iterator.hasNext()) { >+ ITimeEvent currEvent = iterator.next(); > ITimeEvent nextEvent = null; > long currEventTime = currEvent.getTime(); > long nextEventTime = currEventTime; >@@ -1265,8 +1272,8 @@ > while (x0 <= xEnd && null != currEvent) { > boolean stopped = false;// currEvent instanceof > // TsfTmTraceDeadEvent; >- if (idx < count) { >- nextEvent = list.get(idx); >+ if (iterator.hasNext()) { >+ nextEvent = iterator.next(); > nextEventTime = nextEvent.getTime(); > idx++; > } else if (stopped) { >@@ -1408,9 +1415,8 @@ > ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace; > > double x0 = rect.x; >- List<TimeEvent> list = trace.getTraceEvents(); >- // Iterator it = list.iterator(); >- int count = list.size(); >+ long maxDuration = (_timeProvider.getTimeSpace() == 0) ? Long.MAX_VALUE : 1 * (_timeProvider.getTime1() - _timeProvider.getTime0()) / _timeProvider.getTimeSpace(); >+ Iterator<ITimeEvent> iterator = trace.getTraceEventsIterator(_timeProvider.getTime0(), _timeProvider.getTime1(), maxDuration); > // ITimeEvent lastEvent = null; > // if (Trace.isDEBUG()) { > // Trace.debug("\n\t\t\tTrace: " + trace.getName() >@@ -1424,8 +1430,8 @@ > // Clean up to empty line to draw on top > int xEnd = rect.x + rect.width; > fillSpace(rect, gc, selected, _rect1.x, xEnd, xEnd); >- if (count > 0) { >- ITimeEvent currEvent = list.get(0); >+ if (iterator.hasNext()) { >+ ITimeEvent currEvent = iterator.next(); > ITimeEvent nextEvent = null; > long currEventTime = currEvent.getTime(); > long currEventDuration = currEvent.getDuration(); >@@ -1445,8 +1451,8 @@ > // refresh current event duration as the loop moves > currEventDuration = currEvent.getDuration(); > // TsfTmTraceDeadEvent; >- if (idx < count) { >- nextEvent = list.get(idx); >+ if (iterator.hasNext()) { >+ nextEvent = iterator.next(); > nextEventTime = nextEvent.getTime(); > idx++; > } else if (stopped) { >@@ -1485,10 +1491,11 @@ > if (x1 >= rect.x && x0 <= xEnd) { > if (currEventDuration != 0) { > x0 = (double) (x0 >= rect.x ? x0 : rect.x); >- _rect1.width = (int) ((x1 <= xEnd ? x1 : xEnd) - x0); >+ _rect1.width = (int) Math.ceil(x1 <= xEnd ? x1 : xEnd) - (int) x0; > } else { >- _rect1.width = 2; // make punctual events 2 pixels wide >+ _rect1.width = 1; // make punctual events 2 pixels wide > } >+ _rect1.width = Math.max(_minimumItemWidth, _rect1.width); > _rect1.x = (int) x0; > boolean timeSelected = currEventTime <= selectedTime > && selectedTime < nextEventTime; >@@ -1638,17 +1645,29 @@ > public void focusGained(FocusEvent e) { > _isInFocus = true; > redraw(); >- getDisplay().addFilter(SWT.MouseWheel, mouseScrollFilterListener); >+ if (mouseScrollFilterListener == null) { >+ mouseScrollFilterListener = new Listener() { >+ // This filter is used to prevent scrolling of the view when the >+ // mouse wheel is used to zoom >+ public void handleEvent(Event event) { >+ event.doit = false; >+ } >+ }; >+ getDisplay().addFilter(SWT.MouseWheel, mouseScrollFilterListener); >+ } > } > > public void focusLost(FocusEvent e) { > _isInFocus = false; >- if (0 != _dragState) { >+ if (DRAG_NONE != _dragState) { > setCapture(false); >- _dragState = 0; >+ _dragState = DRAG_NONE; > } > redraw(); >- getDisplay().removeFilter(SWT.MouseWheel, mouseScrollFilterListener); >+ if (mouseScrollFilterListener != null) { >+ getDisplay().removeFilter(SWT.MouseWheel, mouseScrollFilterListener); >+ mouseScrollFilterListener = null; >+ } > } > > public boolean isInFocus() { >@@ -1659,7 +1678,7 @@ > if (null == _timeProvider) > return; > Point size = getCtrlSize(); >- if (1 == _dragState) { >+ if (DRAG_TRACE_ITEM == _dragState) { > int nameWidth = _timeProvider.getNameSpace(); > int x = e.x - nameWidth; > if (x > 0 && size.x > nameWidth && _dragX != x) { >@@ -1678,10 +1697,10 @@ > } > _timeProvider.setStartFinishTime(time0, time1); > } >- } else if (3 == _dragState) { >- _dragX = e.x; >- _timeProvider.setNameSpace(_hitIdx + _dragX - _dragX0); >- } else if (0 == _dragState) { >+ } else if (DRAG_SPLIT_LINE == _dragState) { >+ _dragX = e.x; >+ _timeProvider.setNameSpace(_hitIdx + _dragX - _dragX0); >+ } else if (DRAG_NONE == _dragState) { > boolean mouseHover = hitSplitTest(e.x, e.y) > 0; > if (_mouseHover != mouseHover) > redraw(); >@@ -1769,7 +1788,7 @@ > if (namewidth != 0) { > idx = hitSplitTest(e.x, e.y); > if (idx > 0) { >- _dragState = 3; >+ _dragState = DRAG_SPLIT_LINE; > _dragX = _dragX0 = e.x; > _hitIdx = _timeProvider.getNameSpace(); > ; >@@ -1783,40 +1802,49 @@ > idx = hitTest(e.x, e.y); > if (idx >= 0) { > if (_data._items[idx] instanceof TraceItem) { >- long hitTime = hitTimeTest(e.x, e.y); >+ long hitTime = hitTimeTest(e.x); > if (hitTime >= 0) { >- _timeProvider.setSelectedTimeInt(hitTime, false); >+// _timeProvider.setSelectedTimeInt(hitTime, false); > setCapture(true); >- _dragState = 1; >+ _dragState = DRAG_TRACE_ITEM; > _dragX = _dragX0 = e.x - _timeProvider.getNameSpace(); >+ _hitIdx = idx; > _time0bak = _timeProvider.getTime0(); > _time1bak = _timeProvider.getTime1(); >+ return; > } > } else if (_data._items[idx] instanceof GroupItem) { >- _hitIdx = idx; >- _dragState = 2; >+ _dragX0 = e.x; >+ _dragState = DRAG_GROUP_ITEM; > } > selectItem(idx, false); > fireSelectionChanged(); > } else { > selectItem(idx, false); // clear selection >+ redraw(); > } > } > } > > public void mouseUp(MouseEvent e) { >- if (0 != _dragState) { >+ if (DRAG_NONE != _dragState) { > setCapture(false); >- if (1 == _dragState) { >+ if (DRAG_TRACE_ITEM == _dragState) { > // Notify time provider to check the need for listener notification > _timeProvider.notifyStartFinishTime(); >- } else if (2 == _dragState) { >- if (hitTest(e.x, e.y) == _hitIdx) >+ if (_dragX == _dragX0) { // click without drag >+ long time = hitTimeTest(e.x); >+ _timeProvider.setSelectedTimeInt(time, false); >+ selectItem(_hitIdx, false); >+ fireSelectionChanged(); >+ } >+ } else if (DRAG_GROUP_ITEM == _dragState) { >+ if (e.x == _dragX0) // click without drag > toggle(_hitIdx); >- } else if (3 == _dragState) { >+ } else if (DRAG_SPLIT_LINE == _dragState) { > redraw(); > } >- _dragState = 0; >+ _dragState = DRAG_NONE; > } > } > >@@ -1874,7 +1902,7 @@ > } > > public void mouseScrolled(MouseEvent e) { >- if (!_isInFocus) >+ if (!_isInFocus || _dragState != DRAG_NONE) > return; > if (e.count > 0) { > zoom(true); >@@ -1920,6 +1948,10 @@ > this._itemHeight = rowHeight; > } > >+ public void setMinimumItemWidth(int width) { >+ this._minimumItemWidth = width; >+ } >+ > public Vector<ITmfTimeAnalysisEntry> getFilteredOut() { > return _data.getFilteredOut(); > } >@@ -2056,21 +2088,17 @@ > if (trace == null) > return null; > >- int traceId = trace.getId(); >- >- Integer idx = null; > for (int i = 0; i < _items.length; i++) { >- idx = i; > Object item = _items[i]; > if (item instanceof TraceItem) { > TraceItem ti = (TraceItem) item; >- if (ti._trace.getId() == traceId) { >- break; >+ if (ti._trace == trace) { >+ return i; > } > } > } > >- return idx; >+ return null; > } > > public void updateItems() { >@@ -2164,6 +2192,8 @@ > // item = findTraceItem(parent); > // } > >+ /* >+ * Check if this is still needed! > ITmfTimeAnalysisEntry localTraceItem = item._trace; > // Local trace found > Vector<TimeEvent> children = localTraceItem.getTraceEvents(); >@@ -2179,6 +2209,7 @@ > } > // Add the new item > children.add(childItem); >+ */ > > } > >Index: src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TimeScaleCtrl.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TimeScaleCtrl.java (revision 25468) >+++ src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TimeScaleCtrl.java (working copy) >@@ -104,6 +104,9 @@ > unit = MIN_IN_NS; > } else if (minDelta > 20 * SEC_IN_NS) { > unit = 30 * SEC_IN_NS; >+ } else if (minDelta <= 1) { >+ _timeDelta = 1; >+ return; > } > } > double log = Math.log10((double) minDelta / unit); >Index: src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/Utils.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/Utils.java (revision 25468) >+++ src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/Utils.java (working copy) >@@ -18,14 +18,11 @@ > import java.text.SimpleDateFormat; > import java.util.Date; > import java.util.Iterator; >-import java.util.List; > import java.util.TimeZone; >-import java.util.Vector; > > import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer.TimeFormat; > import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent; > import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry; >-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.TimeEvent; > import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.Device; > import org.eclipse.swt.graphics.GC; >@@ -323,11 +320,12 @@ > static ITimeEvent getFirstEvent(ITmfTimeAnalysisEntry thread) { > if (null == thread) > return null; >- Vector<TimeEvent> list = thread.getTraceEvents(); >- ITimeEvent event = null; >- if (!list.isEmpty()) >- event = (ITimeEvent) list.get(0); >- return event; >+ Iterator<ITimeEvent> iterator = thread.getTraceEventsIterator(); >+ if (iterator.hasNext()) { >+ return iterator.next(); >+ } else { >+ return null; >+ } > } > > /** >@@ -343,14 +341,13 @@ > static ITimeEvent findEvent(ITmfTimeAnalysisEntry thread, long time, int n) { > if (null == thread) > return null; >- List<TimeEvent> list = thread.getTraceEvents(); >- Iterator<TimeEvent> it = list.iterator(); >+ Iterator<ITimeEvent> iterator = thread.getTraceEventsIterator(); > ITimeEvent nextEvent = null; > ITimeEvent currEvent = null; > ITimeEvent prevEvent = null; > >- while (it.hasNext()) { >- nextEvent = (ITimeEvent) it.next(); >+ while (iterator.hasNext()) { >+ nextEvent = (ITimeEvent) iterator.next(); > long nextStartTime = nextEvent.getTime(); > > if (nextStartTime > time) { >Index: src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TmfTimeTipHandler.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TmfTimeTipHandler.java (revision 25468) >+++ src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TmfTimeTipHandler.java (working copy) >@@ -107,28 +107,30 @@ > Item item) { > if (item instanceof TraceItem) { > ITmfTimeAnalysisEntry thrd = ((TraceItem) item)._trace; >- ITimeEvent threadEvent = Utils.findEvent(thrd, threadStates >- .hitTimeTest(pt.x, pt.y), 2); >- ITimeEvent nextEvent = Utils.findEvent(thrd, threadStates >- .hitTimeTest(pt.x, pt.y), 1); >+ ITimeEvent threadEvent = Utils.findEvent(thrd, threadStates.hitTimeTest(pt.x), 2); >+ ITimeEvent nextEvent = Utils.findEvent(thrd, threadStates.hitTimeTest(pt.x), 1); > // thread name > addItem(Messages._TRACE_NAME, thrd.getName()); > // class name >- addItem(Messages._TRACE_CLASS_NAME, _utilImp >- .getTraceClassName(thrd)); >+ String traceClass = _utilImp.getTraceClassName(thrd); >+ if (traceClass != null) { >+ addItem(Messages._TRACE_CLASS_NAME, traceClass); >+ } > // thread state >- addItem(Messages._TRACE_STATE, _utilImp >- .getEventName(threadEvent)); >+ String state = _utilImp.getEventName(threadEvent); >+ if (state != null) { >+ addItem(Messages._TRACE_STATE, state); >+ } > > // This block receives a > // list of <String, String> values to be added to the tip > // table >- Map<String, String> eventAddOns = _utilImp >- .getEventHoverToolTipInfo(threadEvent); >- for (Iterator<String> iter = eventAddOns.keySet() >- .iterator(); iter.hasNext();) { >- String message = (String) iter.next(); >- addItem(message, eventAddOns.get(message)); >+ Map<String, String> eventAddOns = _utilImp.getEventHoverToolTipInfo(threadEvent); >+ if (eventAddOns != null) { >+ for (Iterator<String> iter = eventAddOns.keySet().iterator(); iter.hasNext();) { >+ String message = (String) iter.next(); >+ addItem(message, eventAddOns.get(message)); >+ } > } > > long eventStartTime = -1; >Index: src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisEntry.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisEntry.java (revision 0) >+++ src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisEntry.java (revision 0) >@@ -0,0 +1,224 @@ >+package org.eclipse.linuxtools.tmf.ui.views.timechart; >+ >+import java.util.Iterator; >+import java.util.NoSuchElementException; >+import java.util.Vector; >+ >+import org.eclipse.linuxtools.tmf.trace.ITmfTrace; >+import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent; >+import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry; >+ >+public class TimeChartAnalysisEntry implements ITmfTimeAnalysisEntry { >+ >+ private ITmfTrace fTrace; >+ private String fGroup; >+ private Vector<TimeChartEvent> fTraceEvents; >+ private int fPower = 0; // 2^fPower nanoseconds per vector position >+ private long fReferenceTime = -1; // time corresponding to beginning of index 0 >+ private long fStartTime = -1; // time of first event >+ private long fStopTime = -1; // time of last event >+ private long fLastRank = -1; // rank of last processed trace event >+ >+ TimeChartAnalysisEntry(ITmfTrace trace, int modelSize) { >+ fTrace = trace; >+ fTraceEvents = new Vector<TimeChartEvent>(modelSize); >+ } >+ >+ TimeChartAnalysisEntry(ITmfTrace trace, String group, int modelSize) { >+ fTrace = trace; >+ fTraceEvents = new Vector<TimeChartEvent>(modelSize); >+ fGroup = group; >+ } >+ >+ public String getGroupName() { >+ return fGroup; >+ } >+ >+ public int getId() { >+ // TODO Auto-generated method stub >+ return 0; >+ } >+ >+ public String getName() { >+ return fTrace.getName(); >+ } >+ >+ public long getStartTime() { >+ return fStartTime; >+ } >+ >+ public long getStopTime() { >+ return fStopTime; >+ } >+ >+ @Deprecated public <T extends ITimeEvent> Vector<T> getTraceEvents() { >+ return null; >+ } >+ >+ public Iterator<ITimeEvent> getTraceEventsIterator() { >+ return new EntryIterator(0, Long.MAX_VALUE, 0); >+ } >+ >+ public Iterator<ITimeEvent> getTraceEventsIterator(long startTime, long stopTime, long maxDuration) { >+ return new EntryIterator(startTime, stopTime, maxDuration); >+ } >+ >+ private class EntryIterator implements Iterator<ITimeEvent> { >+ private final long fIteratorStartTime; >+ private final long fIteratorStopTime; >+ private final long fIteratorMaxDuration; >+ private long lastTime = -1; >+ private TimeChartEvent next = null; >+ private Iterator<ITimeEvent> nestedIterator = null; >+ >+ public EntryIterator(long startTime, long stopTime, long maxDuration) { >+ fIteratorStartTime = startTime; >+ fIteratorStopTime = stopTime; >+ fIteratorMaxDuration = maxDuration; >+ } >+ >+ public boolean hasNext() { >+ synchronized (fTraceEvents) { >+ if (next != null) return true; >+ if (nestedIterator != null) { >+ if (nestedIterator.hasNext()) { >+ return true; >+ } else { >+ nestedIterator = null; >+ } >+ } >+ long time = (lastTime == -1) ? fStartTime : lastTime; >+ int index = (fReferenceTime == -1) ? 0 : (int) ((time - fReferenceTime) >> fPower); >+ while (index < fTraceEvents.size()) { >+ TimeChartEvent event = fTraceEvents.get(index++); >+ if (event != null && (lastTime == -1 || event.getTime() > time)) { >+ if (event.getTime() + event.getDuration() >= fIteratorStartTime && event.getTime() <= fIteratorStopTime) { >+ if (event.getItemizedEntry() == null || event.getDuration() <= fIteratorMaxDuration) { >+ lastTime = event.getTime() + event.getDuration(); >+ next = event; >+ return true; >+ } else { >+ nestedIterator = event.getItemizedEntry().getTraceEventsIterator(fIteratorStartTime, fIteratorStopTime, fIteratorMaxDuration); >+ return nestedIterator.hasNext(); >+ } >+ } >+ } >+ } >+ return false; >+ } >+ } >+ >+ public TimeChartEvent next() { >+ synchronized (fTraceEvents) { >+ if (nestedIterator != null) { >+ TimeChartEvent event = (TimeChartEvent) nestedIterator.next(); >+ lastTime = event.getTime() + event.getDuration(); >+ return event; >+ } >+ if (hasNext()) { >+ TimeChartEvent event = next; >+ next = null; >+ return event; >+ } >+ throw new NoSuchElementException(); >+ } >+ } >+ >+ public void remove() { >+ throw new UnsupportedOperationException(); >+ } >+ >+ } >+ >+ public void addTraceEvent(ITimeEvent timeEvent) { >+ long time = timeEvent.getTime(); >+ synchronized (fTraceEvents) { >+ long index = (fReferenceTime == -1) ? 0 : (time - fReferenceTime) >> fPower; >+ if (index < 0) { >+ if (fTraceEvents.capacity() - fTraceEvents.size() < -index) { >+ int powershift = (-index + fTraceEvents.size() <= 2 * fTraceEvents.capacity()) ? 1 : >+ (int) Math.ceil(Math.log((double) (-index + fTraceEvents.size()) / fTraceEvents.capacity()) / Math.log(2)); >+ merge(powershift); >+ index = index >> powershift; >+ } >+ shift((int) -index); >+ index = 0; >+ fTraceEvents.set(0, (TimeChartEvent) timeEvent); >+ } else if (index < fTraceEvents.capacity()) { >+ if (index >= fTraceEvents.size()) { >+ fTraceEvents.setSize((int) index + 1); >+ } >+ } else { >+ int powershift = (index < 2 * fTraceEvents.capacity()) ? 1 : >+ (int) Math.ceil(Math.log((double) (index + 1) / fTraceEvents.capacity()) / Math.log(2)); >+ merge(powershift); >+ fTraceEvents.setSize((int) (index >> powershift) + 1); >+ index = (int) (index >> powershift); >+ } >+ TimeChartEvent event = (TimeChartEvent) fTraceEvents.get((int) index); >+ if (event == null) { >+ fTraceEvents.set((int) index, (TimeChartEvent) timeEvent); >+ } else { >+ if (event.getItemizedEntry() == null) { >+ event.merge((TimeChartEvent) timeEvent); >+ } else { >+ event.getItemizedEntry().addTraceEvent(timeEvent); >+ } >+ } >+ } >+ if (fReferenceTime == -1 || time < fReferenceTime) { >+ fReferenceTime = (time >> fPower) << fPower; >+ } >+ if (fStartTime == -1 || time < fStartTime) { >+ fStartTime = time; >+ } >+ if (fStopTime == -1 || time > fStopTime) { >+ fStopTime = time; >+ } >+ } >+ >+ private void merge(int powershift) { >+ fPower += powershift; >+ fReferenceTime = (fReferenceTime >> fPower) << fPower; >+ int index = 0; >+ for (int i = 0; i < fTraceEvents.size(); i++) { >+ TimeChartEvent event = fTraceEvents.get(i); >+ if (event != null) { >+ index = (int) ((event.getTime() - fReferenceTime) >> fPower); >+ TimeChartEvent mergedEvent = (TimeChartEvent) fTraceEvents.get(index); >+ if (mergedEvent == null) { >+ fTraceEvents.set(index, event); >+ } else { >+ mergedEvent.merge(event); >+ } >+ if (i != index) { >+ fTraceEvents.set(i, null); >+ } >+ } >+ } >+ fTraceEvents.setSize(index + 1); >+ } >+ >+ private void shift(int indexshift) { >+ int oldSize = fTraceEvents.size(); >+ fTraceEvents.setSize(oldSize + indexshift); >+ for (int i = oldSize - 1; i >= 0; i--) { >+ fTraceEvents.set(i + indexshift, fTraceEvents.get(i)); >+ } >+ for (int i = 0; i < indexshift; i++) { >+ fTraceEvents.set(i, null); >+ } >+ } >+ >+ public ITmfTrace getTrace() { >+ return fTrace; >+ } >+ >+ public void setLastRank(long rank) { >+ fLastRank = rank; >+ } >+ >+ public long getLastRank() { >+ return fLastRank; >+ } >+} >Index: src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisProvider.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisProvider.java (revision 0) >+++ src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisProvider.java (revision 0) >@@ -0,0 +1,36 @@ >+package org.eclipse.linuxtools.tmf.ui.views.timechart; >+ >+import java.util.Map; >+ >+import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider; >+import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent; >+import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry; >+ >+public class TimeChartAnalysisProvider extends TmfTimeAnalysisProvider { >+ >+ @Override >+ public StateColor getEventColor(ITimeEvent event) { >+ return StateColor.MAGENTA3; >+ } >+ >+ @Override >+ public String getTraceClassName(ITmfTimeAnalysisEntry entry) { >+ return null; >+ } >+ >+ @Override >+ public String getEventName(ITimeEvent event, boolean upper, boolean extInfo) { >+ return null; >+ } >+ >+ @Override >+ public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) { >+ return null; >+ } >+ >+ @Override >+ public String getStateName(StateColor color) { >+ return null; >+ } >+ >+} >Index: src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartEvent.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartEvent.java (revision 0) >+++ src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartEvent.java (revision 0) >@@ -0,0 +1,159 @@ >+package org.eclipse.linuxtools.tmf.ui.views.timechart; >+ >+import java.util.ArrayList; >+import java.util.Iterator; >+ >+import org.eclipse.linuxtools.tmf.event.TmfEvent; >+import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent; >+import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry; >+ >+public class TimeChartEvent implements ITimeEvent { >+ >+ private static final byte TIMESTAMP_SCALE = -9; >+ >+ private TimeChartAnalysisEntry fParentEntry; >+ private long fTime; >+ private long fDuration; >+ private long fFirstRank; >+ private long fLastRank; >+ private RankRangeList fRankRangeList; >+ private long fNbEvents; >+ private TimeChartAnalysisEntry fItemizedEntry; >+ private boolean fItemizing; >+ >+ public TimeChartEvent(TimeChartAnalysisEntry parentEntry, TmfEvent event, long rank) { >+ fParentEntry = parentEntry; >+ fTime = event.getTimestamp().synchronize((long) 0, TIMESTAMP_SCALE).getValue(); >+ fDuration = 0; >+ fFirstRank = fLastRank = rank; >+ fRankRangeList = new RankRangeList(rank); >+ fNbEvents = 1; >+ } >+ >+ public ITmfTimeAnalysisEntry getEntry() { >+ return fParentEntry; >+ } >+ >+ public long getTime() { >+ return fTime; >+ } >+ >+ public long getDuration() { >+ return fDuration; >+ } >+ >+ public long getFirstRank() { >+ return fFirstRank; >+ } >+ >+ public long getLastRank() { >+ return fLastRank; >+ } >+ >+ public RankRangeList getRankRangeList() { >+ return fRankRangeList; >+ } >+ >+ public void merge(TimeChartEvent event) { >+ if (fTime == event.getTime() && fDuration == event.getDuration()) return; >+ long endTime = Math.max(fTime + fDuration, event.getTime() + event.getDuration()); >+ fTime = Math.min(fTime, event.getTime()); >+ fDuration = endTime - fTime; >+ fFirstRank = Math.min(fFirstRank, event.fFirstRank); >+ fLastRank = Math.max(fLastRank, event.fLastRank); >+ fNbEvents += event.fNbEvents; >+ fItemizedEntry = null; >+ fRankRangeList.merge(event.getRankRangeList()); >+ } >+ >+ public long getNbEvents() { >+ return fNbEvents; >+ } >+ >+ public void setItemizedEntry(TimeChartAnalysisEntry timeAnalysisEntry) { >+ fItemizedEntry = timeAnalysisEntry; >+ } >+ >+ public TimeChartAnalysisEntry getItemizedEntry() { >+ return fItemizedEntry; >+ } >+ >+ public boolean isItemizing() { >+ return fItemizing; >+ } >+ >+ public void setItemizing(boolean itemizing) { >+ fItemizing = itemizing; >+ } >+ >+ public class RankRange { >+ private long firstRank; >+ private long lastRank; >+ >+ public RankRange(long firstRank, long lastRank) { >+ this.firstRank = firstRank; >+ this.lastRank = lastRank; >+ } >+ >+ public long getFirstRank() { >+ return firstRank; >+ } >+ >+ public long getLastRank() { >+ return lastRank; >+ } >+ >+ public long distanceFrom(RankRange range) { >+ if (range.lastRank < fFirstRank) { >+ return fFirstRank - range.lastRank; >+ } else if (range.firstRank > fLastRank) { >+ return range.firstRank - fLastRank; >+ } else { >+ return 0; >+ } >+ } >+ >+ public String toString() { >+ return "["+firstRank+","+lastRank+"]"; >+ } >+ } >+ >+ private class RankRangeList extends ArrayList<RankRange> { >+ >+ private static final long serialVersionUID = 6060485531208535986L; >+ >+ public RankRangeList(long rank) { >+ super(1); >+ add(new RankRange(rank, rank)); >+ } >+ >+ public void merge(RankRangeList rankRangeList) { >+ long threshold = fParentEntry.getTrace().getCacheSize(); >+ for (RankRange newRange : rankRangeList) { >+ boolean merged = false; >+ for (RankRange oldRange : fRankRangeList) { >+ if (newRange.distanceFrom(oldRange) <= threshold) { >+ oldRange.firstRank = Math.min(oldRange.firstRank, newRange.firstRank); >+ oldRange.lastRank = Math.max(oldRange.lastRank, newRange.lastRank); >+ merged = true; >+ break; >+ } >+ } >+ if (!merged) { >+ add(newRange); >+ } >+ } >+ Iterator<RankRange> iterator = fRankRangeList.iterator(); >+ RankRange previous = null; >+ while (iterator.hasNext()) { >+ RankRange range = iterator.next(); >+ if (previous != null && range.distanceFrom(previous) <= threshold) { >+ previous.firstRank = Math.min(previous.firstRank, range.firstRank); >+ previous.lastRank = Math.max(previous.lastRank, range.lastRank); >+ iterator.remove(); >+ } >+ previous = range; >+ } >+ } >+ } >+} >Index: src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java >=================================================================== >--- src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java (revision 0) >+++ src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java (revision 0) >@@ -0,0 +1,344 @@ >+package org.eclipse.linuxtools.tmf.ui.views.timechart; >+ >+import java.util.Iterator; >+import java.util.Vector; >+ >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.linuxtools.tmf.event.TmfEvent; >+import org.eclipse.linuxtools.tmf.event.TmfTimestamp; >+import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; >+import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal; >+import org.eclipse.linuxtools.tmf.signal.TmfTraceClosedSignal; >+import org.eclipse.linuxtools.tmf.signal.TmfTraceOpenedSignal; >+import org.eclipse.linuxtools.tmf.signal.TmfTraceSelectedSignal; >+import org.eclipse.linuxtools.tmf.signal.TmfTraceUpdatedSignal; >+import org.eclipse.linuxtools.tmf.trace.ITmfTrace; >+import org.eclipse.linuxtools.tmf.trace.TmfContext; >+import org.eclipse.linuxtools.tmf.ui.editors.ITmfTraceEditor; >+import org.eclipse.linuxtools.tmf.ui.viewers.TmfViewerFactory; >+import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer; >+import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeScaleSelectionListener; >+import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeSelectionListener; >+import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent; >+import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent; >+import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent; >+import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry; >+import org.eclipse.linuxtools.tmf.ui.views.TmfView; >+import org.eclipse.linuxtools.tmf.ui.views.timechart.TimeChartEvent.RankRange; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.ui.IEditorPart; >+import org.eclipse.ui.IEditorReference; >+ >+ >+public class TimeChartView extends TmfView implements ITmfTimeScaleSelectionListener, ITmfTimeSelectionListener { >+ >+ public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.timechart"; >+ >+ private static final byte TIMESTAMP_SCALE = -9; >+ >+ private int fDisplayWidth; >+ private Composite fComposite; >+ private ITimeAnalysisViewer fViewer; >+ private Vector<TimeChartAnalysisEntry> fTimeAnalysisEntries; >+ >+ public TimeChartView() { >+ super("Time Chart"); >+ fDisplayWidth = Display.getDefault().getBounds().width; >+ } >+ >+ @Override >+ public void createPartControl(Composite parent) { >+ fComposite = new Composite(parent, SWT.NONE); >+ GridLayout gl = new GridLayout(); >+ gl.marginWidth = 0; >+ gl.marginHeight = 0; >+ fComposite.setLayout(gl); >+ >+ fViewer = TmfViewerFactory.createViewer(fComposite, new TimeChartAnalysisProvider()); >+ fViewer.groupTraces(false); >+ fViewer.setTimeCalendarFormat(true); >+ fViewer.setAcceptSelectionAPIcalls(true); >+ fViewer.addWidgetTimeScaleSelectionListner(this); >+ fViewer.addWidgetSelectionListner(this); >+ fViewer.setMinimumItemWidth(1); >+ >+ fTimeAnalysisEntries = new Vector<TimeChartAnalysisEntry>(); >+ IEditorReference[] editorReferences = getSite().getPage().getEditorReferences(); >+ for (IEditorReference editorReference : editorReferences) { >+ IEditorPart editor = editorReference.getEditor(false); >+ if (editor instanceof ITmfTraceEditor) { >+ ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace(); >+ if (trace != null) { >+ TimeChartAnalysisEntry timeAnalysisEntry = new TimeChartAnalysisEntry(trace, fDisplayWidth * 2); >+ fTimeAnalysisEntries.add(timeAnalysisEntry); >+ Job job = new ProcessTraceJob(timeAnalysisEntry); >+ job.schedule(); >+ } >+ } >+ } >+ fViewer.display(fTimeAnalysisEntries.toArray(new TimeChartAnalysisEntry[0])); >+ } >+ >+ @Override >+ public void setFocus() { >+ super.setFocus(); >+ fViewer.setFocus(); >+ } >+ >+ private class ProcessTraceJob extends Job { >+ >+ private TimeChartAnalysisEntry fTimeAnalysisEntry; >+ >+ public ProcessTraceJob(TimeChartAnalysisEntry timeAnalysisEntry) { >+ super("ProcessTraceJob:"+timeAnalysisEntry.getName()); >+ fTimeAnalysisEntry = timeAnalysisEntry; >+ setSystem(true); >+ } >+ >+ @Override >+ protected IStatus run(IProgressMonitor monitor) { >+ updateTraceEntry(fTimeAnalysisEntry, Long.MAX_VALUE, 0, Long.MAX_VALUE); >+ return Status.OK_STATUS; >+ } >+ } >+ >+ private void updateTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry, long stopRank, long startTime, long stopTime) { >+ ITmfTrace trace = timeAnalysisEntry.getTrace(); >+ TmfContext context = null; >+ TmfTimestamp lastTimestamp = null; >+ boolean done = false; >+ while (!done) { >+ synchronized (timeAnalysisEntry) { >+ if (timeAnalysisEntry.getLastRank() >= trace.getNbEvents()) { >+ done = true; >+ break; >+ } >+ if (context == null || context.getRank() != timeAnalysisEntry.getLastRank()) { >+ if (timeAnalysisEntry.getLastRank() != -1) { >+ context = trace.seekEvent(timeAnalysisEntry.getLastRank()); >+ } else { >+ //context = trace.seekLocation(null); >+ context = trace.seekEvent(0); >+ } >+ } >+ while (true) { >+ long rank = context.getRank(); >+ TmfEvent event = trace.getNextEvent(context); >+ if (event == null) { >+ done = true; >+ break; >+ } >+ if (!event.getTimestamp().equals(lastTimestamp)) { >+ TimeChartEvent timeEvent = new TimeChartEvent(timeAnalysisEntry, event, rank); >+ if (timeEvent.getTime() >= startTime && timeEvent.getTime() <= stopTime) { >+ timeAnalysisEntry.addTraceEvent(timeEvent); >+ } >+ lastTimestamp = event.getTimestamp(); >+ } >+ if (context.getRank() == trace.getNbEvents() || context.getRank() == stopRank) { >+ done = true; >+ break; >+ } >+ if (context.getRank() % trace.getCacheSize() == 1) { >+ break; >+ } >+ } >+ //timeAnalysisEntry.setLastRank(Math.min(trace.getNbEvents(), stopRank)); >+ timeAnalysisEntry.setLastRank(context.getRank()); >+ } >+ refreshViewer(false); >+ } >+ } >+ >+ private void refreshViewer(boolean resetTimeIntervals) { >+ if (fComposite == null) { >+ return; >+ } >+ final boolean reset = resetTimeIntervals; >+ // Perform the refresh on the UI thread >+ Display.getDefault().asyncExec(new Runnable() { >+ public void run() { >+ if (!fComposite.isDisposed()) { >+ fViewer.display(fTimeAnalysisEntries.toArray(new TimeChartAnalysisEntry[0])); >+ if (reset) { >+ fViewer.resetStartFinishTime(); >+ } >+ } >+ } >+ }); >+ } >+ >+ private void itemize(long startTime, long stopTime) { >+ for (int i = 0; i < fTimeAnalysisEntries.size(); i++) { >+ Job job = new ItemizeJob(fTimeAnalysisEntries.get(i), startTime, stopTime); >+ job.schedule(); >+ } >+ } >+ >+ private class ItemizeJob extends Job { >+ >+ private TimeChartAnalysisEntry fTimeAnalysisEntry; >+ private long fStartTime; >+ private long fStopTime; >+ private long fMaxDuration; >+ >+ private ItemizeJob(TimeChartAnalysisEntry timeAnalysisEntry, long startTime, long stopTime) { >+ super("ItemizeJob:"+timeAnalysisEntry.getName()); >+ fTimeAnalysisEntry = timeAnalysisEntry; >+ fStartTime = startTime; >+ fStopTime = stopTime; >+ setSystem(true); >+ fMaxDuration = 3 * (fStopTime - fStartTime) / fDisplayWidth; >+ } >+ >+ @Override >+ protected IStatus run(IProgressMonitor monitor) { >+ itemizeTraceEntry(fTimeAnalysisEntry); >+ return Status.OK_STATUS; >+ } >+ >+ public void itemizeTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry) { >+ Iterator<ITimeEvent> iterator = timeAnalysisEntry.getTraceEventsIterator(); >+ TimeChartEvent event = null; >+ boolean hasNext = true; >+ while (hasNext) { >+ synchronized (timeAnalysisEntry) { >+ while (hasNext = iterator.hasNext()) { >+ event = (TimeChartEvent) iterator.next(); >+ if (event.getTime() + event.getDuration() > fStartTime && >+ event.getTime() < fStopTime && >+ event.getDuration() > fMaxDuration && >+ event.getNbEvents() > 1) { >+ break; >+ } >+ } >+ } >+ if (hasNext) { >+ if (event.getItemizedEntry() == null) { >+ itemizeEvent((TimeChartEvent) event); >+ } else { >+ itemizeTraceEntry(event.getItemizedEntry()); >+ } >+ } >+ } >+ } >+ >+ public void itemizeEvent(TimeChartEvent event) { >+ synchronized (event) { >+ if (event.isItemizing()) { >+ return; >+ } >+ event.setItemizing(true); >+ } >+ TimeChartAnalysisEntry timeAnalysisEntry = new TimeChartAnalysisEntry(fTimeAnalysisEntry.getTrace(), >+ (int) Math.min(event.getNbEvents() + 1, fDisplayWidth * 2)); >+ for (RankRange range : event.getRankRangeList()) { >+ timeAnalysisEntry.setLastRank(range.getFirstRank()); >+ updateTraceEntry(timeAnalysisEntry, range.getLastRank() + 1, event.getTime(), event.getTime() + event.getDuration()); >+ } >+ event.setItemizedEntry(timeAnalysisEntry); >+ refreshViewer(false); >+ itemizeTraceEntry(timeAnalysisEntry); >+ synchronized (event) { >+ event.setItemizing(false); >+ } >+ } >+ } >+ >+ // ------------------------------------------------------------------------ >+ // Listeners >+ // ------------------------------------------------------------------------ >+ >+ public void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event) { >+ itemize(event.getTime0(), event.getTime1()); >+ } >+ >+ public void tsfTmProcessSelEvent(TmfTimeSelectionEvent event) { >+ ITmfTimeAnalysisEntry timeAnalysisEntry = null; >+ if (event.getSelection() instanceof TimeChartAnalysisEntry) { >+ timeAnalysisEntry = (TimeChartAnalysisEntry) event.getSelection(); >+ } else if (event.getSelection() instanceof TimeChartEvent) { >+ timeAnalysisEntry = ((TimeChartEvent) event.getSelection()).getEntry(); >+ } >+ if (timeAnalysisEntry instanceof TimeChartAnalysisEntry) { >+ broadcast(new TmfTraceSelectedSignal(this, ((TimeChartAnalysisEntry) timeAnalysisEntry).getTrace())); >+ } >+ broadcast(new TmfTimeSynchSignal(this, new TmfTimestamp(event.getSelectedTime(), TIMESTAMP_SCALE))); >+ } >+ >+ // ------------------------------------------------------------------------ >+ // Signal handlers >+ // ------------------------------------------------------------------------ >+ >+ @TmfSignalHandler >+ public void traceOpened(TmfTraceOpenedSignal signal) { >+ if (fTimeAnalysisEntries == null) return; >+ final ITmfTrace trace = signal.getTrace(); >+ TimeChartAnalysisEntry timeAnalysisEntry = null; >+ for (int i = 0; i < fTimeAnalysisEntries.size(); i++) { >+ if (fTimeAnalysisEntries.get(i).getTrace().equals(trace)) { >+ timeAnalysisEntry = fTimeAnalysisEntries.get(i); >+ break; >+ } >+ } >+ if (timeAnalysisEntry == null) { >+ timeAnalysisEntry = new TimeChartAnalysisEntry(trace, fDisplayWidth * 2); >+ fTimeAnalysisEntries.add(timeAnalysisEntry); >+ Job job = new ProcessTraceJob(timeAnalysisEntry); >+ job.schedule(); >+ } >+ refreshViewer(true); >+ } >+ >+ @TmfSignalHandler >+ public void traceClosed(TmfTraceClosedSignal signal) { >+ if (fTimeAnalysisEntries == null) return; >+ final ITmfTrace trace = signal.getTrace(); >+ for (int i = 0; i < fTimeAnalysisEntries.size(); i++) { >+ if (fTimeAnalysisEntries.get(i).getTrace().equals(trace)) { >+ fTimeAnalysisEntries.remove(i); >+ refreshViewer(true); >+ break; >+ } >+ } >+ } >+ >+ @TmfSignalHandler >+ public void traceSelected(TmfTraceSelectedSignal signal) { >+ if (signal.getSource() != this && fTimeAnalysisEntries != null) { >+ ITmfTrace trace = signal.getTrace(); >+ for (int i = 0; i < fTimeAnalysisEntries.size(); i++) { >+ if (fTimeAnalysisEntries.get(i).getTrace().equals(trace)) { >+ fViewer.setSelectedTrace(fTimeAnalysisEntries.get(i)); >+ break; >+ } >+ } >+ } >+ } >+ >+ @TmfSignalHandler >+ public void traceUpdated(TmfTraceUpdatedSignal signal) { >+ if (fTimeAnalysisEntries == null) return; >+ final ITmfTrace trace = signal.getTrace(); >+ for (int i = 0; i < fTimeAnalysisEntries.size(); i++) { >+ TimeChartAnalysisEntry timeAnalysisEntry = fTimeAnalysisEntries.get(i); >+ if (timeAnalysisEntry.getTrace().equals(trace)) { >+ updateTraceEntry(timeAnalysisEntry, Long.MAX_VALUE, 0, Long.MAX_VALUE); >+ break; >+ } >+ } >+ } >+ >+ @TmfSignalHandler >+ public void currentTimeUpdated(TmfTimeSynchSignal signal) { >+ long time = signal.getCurrentTime().synchronize(0, TIMESTAMP_SCALE).getValue(); >+ fViewer.setSelectedTime(time, true, this); >+ } >+ >+} >Index: plugin.xml >=================================================================== >--- plugin.xml (revision 25468) >+++ plugin.xml (working copy) >@@ -26,6 +26,13 @@ > name="Events" > restorable="true"> > </view> >+ <view >+ category="org.eclipse.linuxtools.tmf.ui.views.category" >+ class="org.eclipse.linuxtools.tmf.ui.views.timechart.TimeChartView" >+ id="org.eclipse.linuxtools.tmf.ui.views.timechart" >+ name="Time Chart" >+ restorable="true"> >+ </view> > </extension> > <extension > point="org.eclipse.ui.editors"> >#P org.eclipse.linuxtools.tmf.ui.tests >Index: widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timeAnalysis/test/stub/model/TraceModelImplFactory.java >=================================================================== >--- widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timeAnalysis/test/stub/model/TraceModelImplFactory.java (revision 25468) >+++ widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timeAnalysis/test/stub/model/TraceModelImplFactory.java (working copy) >@@ -83,7 +83,7 @@ > > event = new EventImpl(eventTime, trace, getEventType(i%16)); > event.setDuration(duration); >- trace.getTraceEvents().add(event); >+ trace.addTraceEvent(event); > } > } > >@@ -98,7 +98,7 @@ > // duration = i + (long) ((i % 4)); > event = new EventImpl(eventTime, trace, getEventType(i)); > event.setDuration(duration); >- trace.getTraceEvents().add(event); >+ trace.addTraceEvent(event); > } > } > >Index: widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timeAnalysis/test/stub/model/TraceImpl.java >=================================================================== >--- widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timeAnalysis/test/stub/model/TraceImpl.java (revision 25468) >+++ widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timeAnalysis/test/stub/model/TraceImpl.java (working copy) >@@ -11,10 +11,11 @@ > *******************************************************************************/ > package org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.test.stub.model; > >+import java.util.Iterator; > import java.util.Vector; > >+import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent; > import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry; >-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.TimeEvent; > > > public class TraceImpl implements ITmfTimeAnalysisEntry { >@@ -27,7 +28,7 @@ > private long stopTime = 1; > private String groupName = "defaultGroupName"; > private String className = "defaultClassName"; >- private Vector<TimeEvent> traceEvents = new Vector<TimeEvent>(); >+ private Vector<ITimeEvent> traceEvents = new Vector<ITimeEvent>(); > > // ======================================================================== > // Constructor >@@ -95,9 +96,20 @@ > return stopTime; > } > >- @SuppressWarnings("unchecked") >- public Vector<TimeEvent> getTraceEvents() { >- return traceEvents; >+ @Deprecated public Vector<ITimeEvent> getTraceEvents() { >+ return traceEvents; > } >+ >+ public Iterator<ITimeEvent> getTraceEventsIterator() { >+ return traceEvents.iterator(); >+ } >+ >+ public Iterator<ITimeEvent> getTraceEventsIterator(long startTime, long stopTime, long maxDuration) { >+ return traceEvents.iterator(); >+ } >+ >+ public void addTraceEvent(ITimeEvent event) { >+ traceEvents.add(event); >+ } > > } >Index: widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timeAnalysis/test/stub/views/TsfTraceAnalysisView.java >=================================================================== >--- widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timeAnalysis/test/stub/views/TsfTraceAnalysisView.java (revision 25468) >+++ widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timeAnalysis/test/stub/views/TsfTraceAnalysisView.java (working copy) >@@ -35,10 +35,10 @@ > import org.eclipse.jface.viewers.ViewerSorter; > import org.eclipse.linuxtools.tmf.ui.viewers.TmfViewerFactory; > import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer; >+import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeScaleSelectionListener; > import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeSelectionListener; > import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent; > import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent; >-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeScaleSelectionListener; > import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry; > import org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.test.stub.adaption.TsfImplProvider; > import org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.test.stub.model.EventImpl; >@@ -633,8 +633,6 @@ > + selTrace.getName().toString() > + "\nClass Name: " > + selTrace.getClassName() >- + "\nNumber of Events: " >- + selTrace.getTraceEvents().size() > + "\nSelection Type: " > + event.getDType().toString() > + "\nSelected Time: "
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 325016
:
178665
|
184142
|
184392
|
189664
|
189665