Commit | Line | Data |
---|---|---|
abfad0aa FC |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009, 2010 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.tmf.ui.views.project.dialogs; | |
14 | ||
15 | import java.util.Vector; | |
16 | ||
17 | import org.eclipse.jface.viewers.CheckboxTableViewer; | |
18 | import org.eclipse.jface.wizard.WizardPage; | |
19 | import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfProjectNode; | |
20 | import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfTraceNode; | |
21 | import org.eclipse.swt.SWT; | |
22 | import org.eclipse.swt.layout.FormAttachment; | |
23 | import org.eclipse.swt.layout.FormData; | |
24 | import org.eclipse.swt.layout.FormLayout; | |
25 | import org.eclipse.swt.widgets.Composite; | |
26 | import org.eclipse.swt.widgets.Table; | |
27 | import org.eclipse.swt.widgets.TableColumn; | |
28 | ||
29 | /** | |
30 | * <b><u>AddTraceWizardPage</u></b> | |
31 | * <p> | |
32 | * TODO: Implement me. Please. | |
33 | */ | |
34 | public class AddTraceWizardPage extends WizardPage { | |
35 | ||
36 | private TmfProjectNode fProject; | |
37 | private CheckboxTableViewer fCheckboxTableViewer; | |
38 | ||
39 | protected AddTraceWizardPage(TmfProjectNode project, String pageName) { | |
40 | super(pageName); | |
41 | setTitle("Select traces"); | |
42 | setDescription("Select the traces to add to the experiment"); | |
43 | fProject = project; | |
44 | } | |
45 | ||
d4011df2 | 46 | @Override |
abfad0aa FC |
47 | public void createControl(Composite parent) { |
48 | Composite container = new Composite(parent, SWT.NULL); | |
49 | container.setLayout(new FormLayout()); | |
50 | setControl(container); | |
51 | ||
52 | fCheckboxTableViewer = CheckboxTableViewer.newCheckList(container, SWT.BORDER); | |
53 | fCheckboxTableViewer.setContentProvider(new DialogTraceContentProvider()); | |
54 | fCheckboxTableViewer.setLabelProvider(new DialogTraceLabelProvider()); | |
55 | ||
56 | final Table table = fCheckboxTableViewer.getTable(); | |
57 | final FormData formData = new FormData(); | |
58 | formData.bottom = new FormAttachment(100, 0); | |
59 | formData.right = new FormAttachment(100, 0); | |
60 | formData.top = new FormAttachment(0, 0); | |
61 | formData.left = new FormAttachment(0, 0); | |
62 | table.setLayoutData(formData); | |
63 | table.setHeaderVisible(true); | |
64 | ||
65 | final TableColumn tableColumn = new TableColumn(table, SWT.NONE); | |
66 | tableColumn.setWidth(200); | |
67 | tableColumn.setText("Trace"); | |
68 | ||
69 | fCheckboxTableViewer.setInput(fProject.getTracesFolder()); | |
70 | } | |
71 | ||
72 | public TmfTraceNode[] getSelection() { | |
73 | Vector<TmfTraceNode> traces = new Vector<TmfTraceNode>(); | |
74 | Object[] selection = fCheckboxTableViewer.getCheckedElements(); | |
75 | for (Object sel : selection) { | |
76 | if (sel instanceof TmfTraceNode) | |
77 | traces.add((TmfTraceNode) sel); | |
78 | } | |
79 | TmfTraceNode[] result = new TmfTraceNode[traces.size()]; | |
80 | traces.toArray(result); | |
81 | return result; | |
82 | } | |
83 | ||
84 | } |