Commit | Line | Data |
---|---|---|
4208b510 AM |
1 | /******************************************************************************* |
2 | * Copyright (c) 2015, 2016 EfficiOS Inc., Alexandre Montplaisir | |
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 | ||
10 | package org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.viewers; | |
11 | ||
12 | import org.eclipse.jface.viewers.TableViewer; | |
13 | import org.eclipse.swt.SWT; | |
14 | import org.eclipse.swt.widgets.Composite; | |
15 | import org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiChartModel; | |
3f506e25 | 16 | import org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.views.LamiReportViewTabPage; |
4208b510 AM |
17 | |
18 | /** | |
19 | * Common interface for all Lami viewers. | |
20 | * | |
21 | * @author Alexandre Montplaisir | |
22 | */ | |
23 | public interface ILamiViewer { | |
24 | ||
25 | /** | |
26 | * Dispose the viewer widget. | |
27 | */ | |
28 | void dispose(); | |
29 | ||
30 | /** | |
31 | * Factory method to create a new Table viewer. | |
32 | * | |
33 | * @param parent | |
34 | * The parent composite | |
3f506e25 JR |
35 | * @param page |
36 | * The {@link LamiReportViewTabPage} parent page | |
4208b510 AM |
37 | * @return The new viewer |
38 | */ | |
3f506e25 | 39 | static ILamiViewer createLamiTable(Composite parent, LamiReportViewTabPage page) { |
4208b510 | 40 | TableViewer tableViewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.VIRTUAL); |
3f506e25 | 41 | return new LamiTableViewer(tableViewer, page); |
4208b510 AM |
42 | } |
43 | ||
44 | /** | |
45 | * Factory method to create a new chart viewer. The chart type is specified | |
46 | * by the 'chartModel' parameter. | |
47 | * | |
48 | * @param parent | |
49 | * The parent composite | |
3f506e25 JR |
50 | * @param page |
51 | * The {@link LamiReportViewTabPage} parent page | |
4208b510 AM |
52 | * @param chartModel |
53 | * The information about the chart to display | |
54 | * @return The new viewer | |
55 | */ | |
3f506e25 | 56 | static ILamiViewer createLamiChart(Composite parent, LamiReportViewTabPage page, LamiChartModel chartModel) { |
4208b510 AM |
57 | switch (chartModel.getChartType()) { |
58 | case BAR_CHART: | |
3f506e25 | 59 | return new LamiBarChartViewer(parent, page, chartModel); |
4208b510 | 60 | case XY_SCATTER: |
3f506e25 | 61 | return new LamiScatterViewer(parent, page, chartModel); |
4208b510 AM |
62 | case PIE_CHART: |
63 | default: | |
64 | throw new UnsupportedOperationException("Unsupported chart type: " + chartModel.toString()); //$NON-NLS-1$ | |
65 | } | |
66 | } | |
67 | } |