temporary re-factoring project
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / project / dialogs / AddTraceWizardPage.java
CommitLineData
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
13package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
14
15import java.util.Vector;
16
17import org.eclipse.jface.viewers.CheckboxTableViewer;
8035003b 18import org.eclipse.jface.viewers.IStructuredSelection;
6e512b93 19import org.eclipse.jface.wizard.WizardPage;
8035003b
ASL
20import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngExperimentEntry;
21import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngProject;
22import org.eclipse.linuxtools.lttng.ui.views.project.model.LTTngTraceEntry;
6e512b93
ASL
23import org.eclipse.swt.SWT;
24import org.eclipse.swt.layout.FormAttachment;
25import org.eclipse.swt.layout.FormData;
26import org.eclipse.swt.layout.FormLayout;
27import org.eclipse.swt.widgets.Composite;
28import org.eclipse.swt.widgets.Table;
29import org.eclipse.swt.widgets.TableColumn;
30
31/**
32 * <b><u>AddTraceWizardPage</u></b>
33 * <p>
34 * TODO: Implement me. Please.
35 */
36public class AddTraceWizardPage extends WizardPage {
37
8035003b
ASL
38 private LTTngProject fProject;
39 @SuppressWarnings("unused")
40 private LTTngExperimentEntry fExperiment;
6e512b93
ASL
41 private CheckboxTableViewer fCheckboxTableViewer;
42
8035003b 43 protected AddTraceWizardPage(LTTngProject project, String pageName) {
6e512b93
ASL
44 super(pageName);
45 setTitle("Select traces");
46 setDescription("Select the traces to add to the experiment");
47 fProject = project;
48 }
49
50 public void createControl(Composite parent) {
51 Composite container = new Composite(parent, SWT.NULL);
52 container.setLayout(new FormLayout());
53 setControl(container);
54
55 fCheckboxTableViewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER);
8035003b
ASL
56 fCheckboxTableViewer.setContentProvider(new LTTngTraceContentProvider());
57 fCheckboxTableViewer.setLabelProvider(new LTTngTraceLabelProvider());
6e512b93
ASL
58
59 final Table table = fCheckboxTableViewer.getTable();
60 final FormData formData = new FormData();
61 formData.bottom = new FormAttachment(100, 0);
62 formData.right = new FormAttachment(100, 0);
63 formData.top = new FormAttachment(0, 0);
64 formData.left = new FormAttachment(0, 0);
65 table.setLayoutData(formData);
66 table.setHeaderVisible(true);
67
68 final TableColumn tableColumn = new TableColumn(table, SWT.NONE);
69 tableColumn.setWidth(200);
70 tableColumn.setText("Trace");
71
72 fCheckboxTableViewer.setInput(fProject.getTracesFolder());
73 }
74
8035003b
ASL
75 public void init(IStructuredSelection selection) {
76 Object sel = selection.getFirstElement();
77 if (sel instanceof LTTngExperimentEntry) {
78 fExperiment = (LTTngExperimentEntry) sel;
79 }
80 }
81
82 public LTTngTraceEntry[] getSelection() {
83 Vector<LTTngTraceEntry> traces = new Vector<LTTngTraceEntry>();
6e512b93
ASL
84 Object[] selection = fCheckboxTableViewer.getCheckedElements();
85 for (Object sel : selection) {
8035003b
ASL
86 if (sel instanceof LTTngTraceEntry)
87 traces.add((LTTngTraceEntry) sel);
6e512b93 88 }
8035003b 89 LTTngTraceEntry[] result = new LTTngTraceEntry[traces.size()];
6e512b93
ASL
90 traces.toArray(result);
91 return result;
92 }
93
94}
This page took 0.031986 seconds and 5 git commands to generate.