Commit | Line | Data |
---|---|---|
6e512b93 | 1 | /******************************************************************************* |
8035003b | 2 | * Copyright (c) 2009 Ericsson |
6e512b93 ASL |
3 | * |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Francois Chouinard - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.lttng.ui.views.events; | |
14 | ||
28b94d61 FC |
15 | import org.eclipse.linuxtools.lttng.event.LttngEvent; |
16 | import org.eclipse.linuxtools.lttng.event.LttngEventContent; | |
6e512b93 ASL |
17 | import org.eclipse.linuxtools.tmf.event.TmfEvent; |
18 | import org.eclipse.linuxtools.tmf.ui.views.TmfEventsView; | |
19 | import org.eclipse.swt.SWT; | |
d15fd570 FC |
20 | import org.eclipse.swt.events.SelectionEvent; |
21 | import org.eclipse.swt.events.SelectionListener; | |
6e512b93 ASL |
22 | import org.eclipse.swt.widgets.Table; |
23 | import org.eclipse.swt.widgets.TableColumn; | |
24 | ||
25 | /** | |
26 | * <b><u>EventsView</u></b> | |
27 | * <p> | |
28 | * TODO: Implement me. Please. | |
29 | */ | |
30 | public class EventsView extends TmfEventsView { | |
31 | ||
62d1696a | 32 | public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.events"; |
6e512b93 | 33 | |
8035003b | 34 | // ======================================================================== |
6e512b93 | 35 | // Table data |
8035003b | 36 | // ======================================================================== |
6e512b93 ASL |
37 | |
38 | // Table column names | |
39 | private final String TIMESTAMP_COLUMN = "Timestamp"; | |
40 | private final String SOURCE_COLUMN = "Source"; | |
41 | private final String TYPE_COLUMN = "Type"; | |
42 | private final String REFERENCE_COLUMN = "Reference"; | |
43 | private final String CONTENT_COLUMN = "Content"; | |
44 | private final String[] columnProperties = new String[] { | |
45 | TIMESTAMP_COLUMN, | |
46 | SOURCE_COLUMN, | |
47 | TYPE_COLUMN, | |
48 | REFERENCE_COLUMN, | |
49 | CONTENT_COLUMN | |
50 | }; | |
51 | ||
52 | // Column data | |
53 | private class ColumnData { | |
54 | public final String header; | |
55 | public final int width; | |
56 | public final int alignment; | |
57 | ||
58 | public ColumnData(String h, int w, int a) { | |
59 | header = h; | |
60 | width = w; | |
61 | alignment = a; | |
62 | } | |
63 | }; | |
64 | ||
65 | private ColumnData[] columnData = new ColumnData[] { | |
8035003b | 66 | new ColumnData(columnProperties[0], 100, SWT.LEFT), |
6e512b93 | 67 | new ColumnData(columnProperties[1], 100, SWT.LEFT), |
8035003b ASL |
68 | new ColumnData(columnProperties[2], 100, SWT.LEFT), |
69 | new ColumnData(columnProperties[3], 100, SWT.LEFT), | |
6e512b93 ASL |
70 | new ColumnData(columnProperties[4], 100, SWT.LEFT) |
71 | }; | |
72 | ||
8035003b | 73 | // ======================================================================== |
6e512b93 | 74 | // Constructor |
8035003b | 75 | // ======================================================================== |
6e512b93 ASL |
76 | |
77 | public EventsView() { | |
6e512b93 ASL |
78 | } |
79 | ||
d15fd570 FC |
80 | /** |
81 | * @param table | |
82 | * | |
83 | * FIXME: Add support for column selection | |
84 | */ | |
85 | @Override | |
8035003b | 86 | protected void setColumnHeaders(Table table) { |
6e512b93 | 87 | for (int i = 0; i < columnData.length; i++) { |
d15fd570 | 88 | final TableColumn column = new TableColumn(table, columnData[i].alignment, i); |
6e512b93 ASL |
89 | column.setText(columnData[i].header); |
90 | column.setWidth(columnData[i].width); | |
d15fd570 FC |
91 | // TODO: Investigate why the column resizing doesn't work by default |
92 | // Anything to do with SWT_VIRTUAL? | |
93 | column.addSelectionListener(new SelectionListener() { | |
94 | public void widgetDefaultSelected(SelectionEvent e) { | |
95 | // TODO Auto-generated method stub | |
96 | } | |
97 | public void widgetSelected(SelectionEvent e) { | |
98 | column.pack(); | |
99 | } | |
100 | }); | |
6e512b93 | 101 | } |
d15fd570 | 102 | } |
6e512b93 ASL |
103 | |
104 | /** | |
105 | * @param event | |
106 | * @return | |
107 | */ | |
108 | @Override | |
109 | protected String[] extractItemFields(TmfEvent event) { | |
110 | String[] fields = new String[0]; | |
28b94d61 | 111 | |
6e512b93 ASL |
112 | if (event != null) { |
113 | fields = new String[] { | |
114 | event.getTimestamp().toString(), | |
115 | event.getSource().toString(), | |
116 | event.getType().toString(), | |
117 | event.getReference().toString(), | |
28b94d61 FC |
118 | ((LttngEventContent)event.getContent()).toString() |
119 | }; | |
6e512b93 ASL |
120 | } |
121 | return fields; | |
122 | } | |
123 | ||
8d2e2848 FC |
124 | /* (non-Javadoc) |
125 | * @see java.lang.Object#toString() | |
126 | */ | |
127 | @Override | |
128 | public String toString() { | |
129 | return "[EventsView]"; | |
130 | } | |
131 | ||
132 | ||
6e512b93 | 133 | } |