DESCRIPTION

TMF: Consolidate some view code into the AbstractBarChartView

This new view is a base view for all views using the TimeGraphCombo widget.
As a first step, the lttng2 kernel Control flow view and Resources view have
been modified to extend this abstract view.

Mostly all of the interface management code (build thread, zoom thread, signal
handling, etc) is in the base class.  Final views need only implement to code
to fill the entries' list and events.

This patch includes:
- The abstract view class that all new bar chart views may extend.  The default
   weight of each sash can be set in the constructor.
- A BarChartEntry class that can be used as is if the view does not require
  extra data of its entries
- A BarChartEvent class that can be used as is most of the time
- A BarChartPresentationProvider that present the mechanics of what the view's
  presentation provider should look like.  A view may or may not extend it.
- Added a ITimeGraphDrawingHelper interface to pass to the presentation
  providers to help them get the information they need to know where to draw
  some things (see ResourcesPresentationProvider)

It is a first step before adding new features to the bar chart views.  Some
more abstraction may need to be done as well as other reorganizing of the
code.

Change-Id: I73c9f1b4bf8ec265f1b02804fa7f819bd2b8dd7a
Signed-off-by: Aryana Jones xxx@xxx.xxx


COMMENTS

author: Annalise Jimenez
date: 2013-05-08 14:27:51.000000000

Uploaded patch set 5.

-------------------------------------
author: Brenden Conley
date: 2013-05-08 14:27:56.000000000

Patch Set 5:

Build Started https://hudson.eclipse.org/sandbox/job/linuxtools/2207/ 

-------------------------------------
author: Brenden Conley
date: 2013-05-08 14:43:26.000000000

Patch Set 5: Verified

Build Successful 

https://hudson.eclipse.org/sandbox/job/linuxtools/2207/ : SUCCESS

-------------------------------------
author: Luciana Barry
date: 2013-05-10 19:27:10.000000000

Patch Set 5: I would prefer that you didn't submit this

(20 inline comments)

I would prefer for the view to be called AbstractTimeGraphView (if so, don't forget to update commit title).

See the individual file comments, the BarChart* classes could instead have their code added to existing or new TimeGraph*/TimeEvent classes in the o.e.l.t.u.w.timegraph package.

Line:25, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/ITmfTimeGraphDrawingHelper.java -> Alternative: add a method setTimeGraphControl to ITimeGraphPresentationProvider, and have the time graph control call it to store itself in the provider when setTimeGraphProvider is received.
Then TimeGraphPresentationProvider subclasses have direct access to the time graph control in all postDraw methods.

Line:52, lttng/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/controlflow/ControlFlowView.java -> Should stay as 'ID' as it is referenced in the PerspectiveFactory.

Line:24, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/barchart/IEnumState.java -> Not sure if this interface is really needed

Line:341, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TimeGraphCombo.java -> would prefer to use the same parameter as SashForm (int[])

Line:25, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/barchart/BarChartEntry.java -> not Control Flow view

Line:29, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/barchart/BarChartEntry.java -> We could add a TimeGraphEntry base class in o.e.l.t.u.w.timegraph.model package.
It should not have a quark, the abstract view does not require use of the state system. The quark can be stored in a subclass if required.

Line:208, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/barchart/BarChartEntry.java -> we can avoid this method by having the view implementation provide its own subclass of TreeLabelProvider with the required specific logic

Line:45, lttng/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/views/resources/ResourcesView.java -> Should stay as 'ID' as it is referenced in the PerspectiveFactory.

Line:31, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/barchart/BarChartPresentationProvider.java -> This feels like a wrapper with no real benefit, since all the logic must be in the subclass, which can simply follow the ITimeGraphPresentationProvider interface.

Line:23, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/barchart/BarChartEvent.java -> we could just add a 'value' to the base class TimeEvent

Line:29, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/barchart/BarChartEvent.java -> perhaps Integer.MIN_VALUE

Line:28, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/barchart/EventIterator.java -> EventIterator has recently been moved to o.e.l.t.u.w.timegraph.model package, so this copy is not required.

Line:74, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/barchart/AbstractBarChartView.java -> The abstract view should not have an ID as it will never be referenced in a plugin.xml extension.

Line:91, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/barchart/AbstractBarChartView.java -> there should be a getter for the combo as some views might want to customize it (e.g. add special listeners)

Line:205, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/barchart/AbstractBarChartView.java -> We could make this class visible to subclasses, so they could extend it and call setTreeLabelProvider(TreeLabelProvider) in their constructor.

Line:240, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/barchart/AbstractBarChartView.java -> This ordering is specific to the ControlFlowView. Default behavior should be to not have a comparator at all (leave entries in the order they were built). The sorting could be conditional on non-null comparator. I wouldn't even put a constructor option for it, you could just create a method setComparator(Comparator<ITimeGraphEntry>) that can be called from the specific view's constructor.

Line:267, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/barchart/AbstractBarChartView.java -> no need for 'name' parameter, could just use fName

Line:293, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/barchart/AbstractBarChartView.java -> no need for 'name' parameter, could just use fName

Line:366, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/barchart/AbstractBarChartView.java -> I would prefer to keep weight out of constructor parameters, and instead add a method setWeights(int[]), that can be used to override a default of {1,1}

Line:571, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/barchart/AbstractBarChartView.java -> The idea was that if you synch to a random time (e.g. clicking on histogram) you only change the selected time, but if you click on a state-changing event, its event time will match the start of a state interval, and then you select that entry and make it visible (scroll to it), so you see the state change that results from the selected event.
This might be a view-specific handling and maybe not belong in the abstract class.

-------------------------------------
author: Annalise Jimenez
date: 2013-05-10 19:54:13.000000000

Patch Set 5: (1 inline comment)

Patrick,

Thanks for your comments.  I created all those new classes to avoid having to touch the tmf timegraph widgets and classes that may have been meant to have a more generic functionnality.  But if you give me to OK to merge BarChart* to Timegraph*, I'll be glad to!

Line:25, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/ITmfTimeGraphDrawingHelper.java -> The main reason why I did this interface and passed it in the postDrawX methods was so that I didn't have to expose the full interface of the TimeGraphControl in the PresentationProvider, but only provide the functionnality that a presentation layer may need.

I could use a setter to set the time graph control as this interface though, so as not to double the number of postDraw function calls.  But I'd really prefer not to expose the TimeGraphControl

-------------------------------------
author: Luciana Barry
date: 2013-05-13 15:42:39.000000000

Patch Set 5: (1 inline comment)

OK!

Line:25, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/ITmfTimeGraphDrawingHelper.java -> Sounds good. We might augment this interface in the future, for example to get the position of another event or entry (could be useful for drawing arrows between events).

-------------------------------------
