DESCRIPTION

tmf: Add TmfEventTableColumn class

Introduce the concept of "event table column" objects. This
object will contain:
- The initial column configuration (previously in "ColumnData")
- The "functor" defining how to populate the cell in this column
  for a given event.

The base framework now defines 3 columns, that are available for
all trace types (whose getter methods are currently in ITmfEvent):
- Timestamp
- Event Type
- Contents (fields)

Every trace type can now specify which columns it wants to display,
which may or may not include the default-provided ones.

This is the first step towards decoupling the trace type, event table,
and column order and number. This will eventually allow displaying all
the possible trace type columns in an experiment of heterogeneous traces.

Change-Id: I4ffdb0564114a92a58a271a7a99d3ca43fa57e31
Signed-off-by: Braxton Mccarthy xxx@xxx.xxx


COMMENTS

author: Braxton Mccarthy
date: 2014-08-04 21:04:07.000000000

Uploaded patch set 3.

-------------------------------------
author: Braxton Mccarthy
date: 2014-08-04 21:17:41.000000000

Patch Set 3:

phew, after some more time, here's a new should-be-working version!

So I ended up keeping the source and reference columns for now, for not breaking existing trace types that extend TmfEventTable.

I also added a "wrapper" for the ColumnData constructor to keep working, but couldn't test it in any way...

-------------------------------------
author: Brenden Conley
date: 2014-08-04 21:22:56.000000000

Patch Set 3:

Build Started https://hudson.eclipse.org/linuxtools/job/linuxtools-gerrit/8070/

-------------------------------------
author: Brenden Conley
date: 2014-08-04 22:02:45.000000000

Patch Set 3: Verified+1

Build Successful 

https://hudson.eclipse.org/linuxtools/job/linuxtools-gerrit/8070/ : SUCCESS

-------------------------------------
author: Luciana Barry
date: 2014-08-05 20:28:02.000000000

Patch Set 3: Code-Review-1

(30 comments)

Line:35, lttng/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/viewers/events/LTTng2EventsTable.java -> CHANNEL_HEADER might be more appropriate

Line:47, lttng/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/viewers/events/LTTng2EventsTable.java -> Searching/filtering does not work, it looks for a content field called 'Channel'.

Line:49, lttng/org.eclipse.linuxtools.gdbtrace.ui/src/org/eclipse/linuxtools/internal/gdbtrace/ui/views/events/GdbEventsTable.java -> The alignment is lost.

Line:124, lttng/org.eclipse.linuxtools.gdbtrace.ui/src/org/eclipse/linuxtools/internal/gdbtrace/ui/views/events/GdbEventsTable.java -> The alignment can be set manually here.

Line:57, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventViewer.java -> Searching/filtering does not work, it looks for a content field called 'Source'.

Line:82, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventViewer.java -> Searching/filtering does not work, it looks for a content field called 'Target'.

Line:85, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventViewer.java -> I also question the use of the reference to store the target, but that is another issue.

Line:120, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventViewer.java -> Searching/filtering does not work correctly because of comments below. The table does not show the same as the 'Notes' content field value's string representation.

Line:125, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventViewer.java -> I would think an empty string would be better than "Notes=null" but that is old code...

Line:128, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventViewer.java -> Should be notesField.getValue().toString() to show "abc" instead of "Notes=abc".

Line:46, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/columns/TmfEventTableColumn.java -> To me, that sounds a bit presumptuous.

Line:76, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/columns/TmfEventTableColumn.java -> If the 'field id' was part of the column data it would tie nicely to the current searching/filtering functionality. This can later be revisited if the filter mechanism is modified.

Line:194, lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomEvent.java -> Should we add some kind of bounds check here?

Line:921, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java -> We lose width and alignment functionality. But it can be set manually by the table subclass. However will it still work if the columns are ever created by a column chooser or a plug-in extension (is that planned?)?

Line:926, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java -> We actually don't need to track 'i', without it the new TableColumn is added at the end of the list.

Line:935, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java -> TmfVirtualTable should have no knowledge of such things. It doesn't necessary have to be an event table. Which makes me realize that the type of column should be more generic, we just need an interface that provides the header name and tool tip (TmfEventTableColumn could implement this interface).

Line:942, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java -> (wherever the setting of FIELD_ID ends up, Source and Reference were missing)

Line:952, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java -> I believe pack() is a better default behavior.

Line:61, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomEventsTable.java -> It's really more an index into the custom event column data array, than an id.

Line:84, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomEventsTable.java -> LinkedList :(

Line:58, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/columns/TmfEventTableFieldColumn.java -> It would be nice to have a constructor with separate header and field name.

Line:29, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/text/TmfTextEventTable.java -> This is slightly confusing. The subclasses should migrate to TmfEventsTable (using the constructor with the described columns).

Line:302, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> Please do not use LinkedList unless you need to optimize performance due to multiple inserts and removes in the middle of the list.

Line:356, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> No need for LinkedList here

Line:360, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> If we want to be fully backwards compatible the column should make use of the table's getItemStrings() method. I suspect pcap will not blend well.

Line:375, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> I wouldn't mention this, there might be some more base columns in the future that don't normally belong (e.g. Rank, Delta, Trace, etc.). Or Source and Reference ;)

Line:385, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> pata wuz here

Line:415, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> Is it really our responsibility to do this? But if so, seems like there are some unnecessary steps.

Line:1983, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> Not sure this is necessary and that previous method needs to be deprecated. Perhaps you can wait for reordering patch to see if it's required.

Line:70, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/commands/ExportToTextRequest.java -> Change probably not necessary as long as getItemStrings() uses the current order.

-------------------------------------
author: Braxton Mccarthy
date: 2014-08-05 21:45:52.000000000

Patch Set 3:

(22 comments)

Thanks for the thorough review! Some answers. I'll experiment with saving a FIELD_ID within the column for now so that filtering keeps working.

Line:35, lttng/org.eclipse.linuxtools.lttng2.kernel.ui/src/org/eclipse/linuxtools/internal/lttng2/kernel/ui/viewers/events/LTTng2EventsTable.java -> I am agree

Line:49, lttng/org.eclipse.linuxtools.gdbtrace.ui/src/org/eclipse/linuxtools/internal/gdbtrace/ui/views/events/GdbEventsTable.java -> gaaah, I though it was SWT.LEFT everywhere, which is why I removed it from the API and defaulted to always use it. Hmm.... this particular class will continue extending TmfEventsTable, so we could set it at the constructor like you mention.

Or is it an option we'd want to make available in TmfEventTableColumn?

Line:57, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventViewer.java -> Ok, some more tweaks will have to be done to make filtering work. I'll try to find a way that keeps it simple without refactoring the whole filtering mechanisms right away.

Line:128, lttng/org.eclipse.linuxtools.btf.ui/src/org/eclipse/linuxtools/btf/ui/BtfEventViewer.java -> True, in fact if I'm not mistaken all the other columns would show bla=blabla before this patch, so might as well fix this one too!

Line:46, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/columns/TmfEventTableColumn.java -> The more "common" columns there are, the cleaner it is when we merge columns together for experiments.

Although I agree that, with Source and Reference in there atm, maybe this isn't a good suggestion ;)

Line:76, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/columns/TmfEventTableColumn.java -> Good idea, this could be a nice transition mechanism.

Line:194, lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomEvent.java -> True, although the index should only come from existing columns?

Line:921, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java -> Yeah that was the point, don't offer the knob if it's not needed.

We could still allow it if we want, but that's one extra parameter to carry around.

Line:926, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java -> ooh, good to know!

Line:935, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java -> Yeah I didn't like putting it here either, hence the TODO below.

But if we put the FIELD_ID inside the TmfEventTableColumn for now, we could just call

  tableCol.setData(Key.FIELD_ID, column.getFieldId());

once here.

Default would be to return the fieldName, and it can be overriden by subclasses (like the BTF ones that use Source without it being a TmfSourceColumn()).

Line:942, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java -> ooh, nice catch, that might explain why source/ref filtering was not working. But these could be move to the column itself now.

Line:952, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java -> In most existing case, it would pass 100 to the ColumnData constructor, which resulted in this branch being taken here. But .pack() makes more sense (and we don't have to specify a width anywhere then).

Line:61, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomEventsTable.java -> I renamed it "id" so that it remains decoupled from the underneath implementation, which is still a List here. We could call it index, I don't really care.

Line:84, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/parsers/custom/CustomEventsTable.java -> what's wrong with LinkedList? We only iterate on the resulting list in order (the API mentions Collection anyway ;))

Line:58, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/columns/TmfEventTableFieldColumn.java -> Agreed, in fact I had it that ways at first, but it was getting confusing with all the strings ;)

Right now, every single implementation (that I know of) uses the same header and filed name in both cases. But I kept the fFieldName field separate (from super.getHeaderName()) even though they will always have the same value. So if we want to add a new constructor with those two separate it'd be quite straightforward to do so.

Would you like/need such a constructor right away?

Line:29, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/text/TmfTextEventTable.java -> good point, will reword

Line:302, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> This list will be meant to track the current ordering of the columns in the reorder-columns patch, so we will re-order the elements anywhere in the list. And with colum-hiding, this will mean adding new elements in the list anywhere.

(this will probably need separate lists for the "possible columns" and the visible ones. we'll see once we get there!)

Line:356, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> again, what's wrong with LinkedList? Although here we could initialize the capacity of an ArrayList to columnData.length, in which case the creation time would be similar.

But we pass both as a Collection, and we only iterate on them, so there shouldn't be much difference.

Line:360, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> We can fix pcap. We have the technology. We can rebuild it. We can make it faster, stronger.

Line:375, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> k

Line:415, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> Yeah right now it doesn't do anything, other than fixing a potentially buggy insert by whoever called the constructor.

But with the following patches that work for experiments too, if we have an experiment of similar trace types that have "similar" columns (TmfEventTableFieldColumns with the same field name for example), this is what will merge them together. Else we'd get duplicate columns all the time.

And yeah, there doesn't seem to a more straightforward way to remove duplicates elements from a Collection. At least until .stream().distinct() ;)

Line:1983, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> I did so to really outline that while code might continue compiling, it should be updated. This will force the maintainer to look at the javadoc, see xxx@xxx.xxx comment and explanation etc.

It's only really used by the exportToTextRequest, or else I wouldn't even have added the new version.

-------------------------------------
author: Luciana Barry
date: 2014-08-06 14:23:18.000000000

Patch Set 3:

(9 comments)

Line:49, lttng/org.eclipse.linuxtools.gdbtrace.ui/src/org/eclipse/linuxtools/internal/gdbtrace/ui/views/events/GdbEventsTable.java -> With this patch it can always be set in the constructor, but thinking ahead if there is ever a column chooser the column would be created outside of the event table constructor.

Line:186, lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomEvent.java -> means > mean. However, instead of saying what it's not, we could be more specific (e.g. index of the custom field in the event content?)

Line:194, lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/parsers/custom/CustomEvent.java -> Yes, it's just that the method is public so could be called some other way.

Line:935, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java -> Actually thinking about it now, I've convinced myself that all this should be taken out of here. We should just have a method (with style argument, and maybe an index) that creates a single TableColumn and returns it. Everything else (setting the header, tool tip, width, field id) should be handled by the TmfEventsTable, which has knowledge of the TmfEventTableColum concept (or any other user of TmfVirtualTable doing something completely different). So then there's no need for any ColumnData type or equivalent interface. Note that the method must also add the resize listener (line 951) since that is virtual table specific handling.

Line:58, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/columns/TmfEventTableFieldColumn.java -> I think so. There's many uses, from having the readable name of a field different than its name inside the content, to using a special field id for specific processing. By looking at BTF, maybe the base columns could use constructors with a different header name also...

Line:356, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> LinkedList has to keep three references per item, so along with the extra processing it takes a lot more memory. I don't think the ArrayList resizing (if it can't be avoided) is more costly than building all the links. So I don't believe that LinkedList is better than ArrayList at anything except multiple insertions and removals. But in our case here, all the above is meaningless because we have a small list that isn't used in a way where performance or memory is a factor. So my main objection to unnecessarily using LinkedList anywhere is that it's a pain to debug in JDT.

Line:415, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> But whoever is passing the list to the constructor should do their own duplicate check? If they want to see the same column three times who are we to decide that they are wrong? ;)

Line:418, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> Since it's the constructor and there are no other columns, you could do it in one line with:
fColumns = new ArrayList<>(new LinkedHashSet<>(columns));

Line:1983, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> The method has always returned the strings from the non-hidden columns in the current sort order. So if we introduce column hiding and reordering, it's up to us to modify this method so that it still returns that. Then there really is no update needed by the external users of this method. It's just us that can't use it anymore from setItemData(). There it should either use the table's getColumnOrder(), or do it in a loop with one setText(int, String) per column.

-------------------------------------
author: Braxton Mccarthy
date: 2014-08-06 21:36:42.000000000

Patch Set 3:

(4 comments)

Line:935, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java -> Either the TmfVirtualTable has to know about the concept of TmfEventTableColumn, OR TmfEventsTable has to know about TableColumn. We have to connect them somewhere ;) I'd say I slightly prefer the former, but both could work.

I'd do this in a separate patch though, this one already introduces a lot of changes. (this new method here is just a "rename" of the setColumnHeader(ColumnData[]))

Line:952, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java -> In fact a pack() that adds 1-2 characters worth of spacing would look nicer, imo... future todo?

Line:356, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> If your objects are bigger than 32/64 bits, and most of the time they are, then it's not "a lot more memory", because a reference is small compared to the size of the element itself. But like you say, no matter what we choose here, it won't matter since there will always be so few elements.

In fact, that list here isn't meant to be modified afterwards anyway (the constructor will just copy the elements into its own list), so I should have used ImmutableList!

Line:415, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java -> Ok I see what you mean. With the new "paradigm" it will be TmfUiUtils that will read the extension point for the traces, get the columns from all of them and put them together, then create the TmfEventsTable with it. But that guy could remove the duplicates before calling TmfEventsTable's contructor. So yeah maybe it's not our responsibility here to do it.

-------------------------------------
author: Luciana Barry
date: 2014-08-07 15:36:46.000000000

Patch Set 3:

(2 comments)

Line:935, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java -> I don't really agree with the first option, it is not in the spirit of the design of this class. It was intended as a widget replacement for SWT's Table, totally unaware of the concepts of TMF events or fields.
This method exists because you can't pass a TmfVirtualTable in the constructor of a SWT TableColumn. Here's an idea:

TableColumn column = new TableColumn(table, style, index);

could be replaced with:

TableColumn column = vtable.newTableColumn(style, index);

Line:952, lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/virtualtable/TmfVirtualTable.java -> I would guess this is because you're using Linux. In Windows the default pack() gives a visually appealing output ;)

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