- Fixed a bunch of warnings
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / events / EventsView.java
1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
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
15 import org.eclipse.linuxtools.lttng.event.LttngEventContent;
16 import org.eclipse.linuxtools.tmf.event.TmfEvent;
17 import org.eclipse.linuxtools.tmf.ui.views.TmfEventsView;
18 import org.eclipse.swt.SWT;
19 import org.eclipse.swt.events.SelectionEvent;
20 import org.eclipse.swt.events.SelectionListener;
21 import org.eclipse.swt.widgets.Table;
22 import org.eclipse.swt.widgets.TableColumn;
23
24 /**
25 * <b><u>EventsView</u></b>
26 * <p>
27 * TODO: Implement me. Please.
28 */
29 public class EventsView extends TmfEventsView {
30
31 public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.events";
32
33 // ========================================================================
34 // Table data
35 // ========================================================================
36
37 // Table column names
38 private final String TIMESTAMP_COLUMN = "Timestamp";
39 private final String SOURCE_COLUMN = "Source";
40 private final String TYPE_COLUMN = "Type";
41 private final String REFERENCE_COLUMN = "Reference";
42 private final String CONTENT_COLUMN = "Content";
43 private final String[] columnProperties = new String[] {
44 TIMESTAMP_COLUMN,
45 SOURCE_COLUMN,
46 TYPE_COLUMN,
47 REFERENCE_COLUMN,
48 CONTENT_COLUMN
49 };
50
51 // Column data
52 private class ColumnData {
53 public final String header;
54 public final int width;
55 public final int alignment;
56
57 public ColumnData(String h, int w, int a) {
58 header = h;
59 width = w;
60 alignment = a;
61 }
62 };
63
64 private ColumnData[] columnData = new ColumnData[] {
65 new ColumnData(columnProperties[0], 100, SWT.LEFT),
66 new ColumnData(columnProperties[1], 100, SWT.LEFT),
67 new ColumnData(columnProperties[2], 100, SWT.LEFT),
68 new ColumnData(columnProperties[3], 100, SWT.LEFT),
69 new ColumnData(columnProperties[4], 100, SWT.LEFT)
70 };
71
72 // ========================================================================
73 // Constructor
74 // ========================================================================
75
76 public EventsView() {
77 }
78
79 /**
80 * @param table
81 *
82 * FIXME: Add support for column selection
83 */
84 @Override
85 protected void setColumnHeaders(Table table) {
86 for (int i = 0; i < columnData.length; i++) {
87 final TableColumn column = new TableColumn(table, columnData[i].alignment, i);
88 column.setText(columnData[i].header);
89 column.setWidth(columnData[i].width);
90 // TODO: Investigate why the column resizing doesn't work by default
91 // Anything to do with SWT_VIRTUAL?
92 column.addSelectionListener(new SelectionListener() {
93 public void widgetDefaultSelected(SelectionEvent e) {
94 // TODO Auto-generated method stub
95 }
96 public void widgetSelected(SelectionEvent e) {
97 column.pack();
98 }
99 });
100 }
101 }
102
103 /**
104 * @param event
105 * @return
106 */
107 @Override
108 protected String[] extractItemFields(TmfEvent event) {
109 String[] fields = new String[0];
110
111 if (event != null) {
112 fields = new String[] {
113 event.getTimestamp().toString(),
114 event.getSource().toString(),
115 event.getType().toString(),
116 event.getReference().toString(),
117 ((LttngEventContent)event.getContent()).toString()
118 };
119 }
120 return fields;
121 }
122
123 /* (non-Javadoc)
124 * @see java.lang.Object#toString()
125 */
126 @Override
127 public String toString() {
128 return "[EventsView]";
129 }
130
131
132 }
This page took 0.040232 seconds and 5 git commands to generate.