1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package pl.edu.agh.cast.importer.wizard.page;
19
20 import java.util.LinkedList;
21 import java.util.List;
22
23 import org.eclipse.swt.SWT;
24 import org.eclipse.swt.layout.FillLayout;
25 import org.eclipse.swt.layout.GridData;
26 import org.eclipse.swt.layout.GridLayout;
27 import org.eclipse.swt.widgets.Composite;
28
29 import pl.edu.agh.cast.importer.base.data.RawTabularData;
30 import pl.edu.agh.cast.importer.base.parser.analyzer.IAnalyzer;
31 import pl.edu.agh.cast.importer.base.util.DataTypeInfo;
32 import pl.edu.agh.cast.importer.wizard.utils.ComboBoxTableCreator;
33
34
35
36
37
38
39 public class AnalyzersSelectionPageComposite extends Composite {
40
41 private Composite rootContainer;
42
43 private ComboBoxTableCreator tableCreator;
44
45 private AnalyzersSelectionPage mediator;
46
47
48
49
50
51
52
53
54
55
56
57 public AnalyzersSelectionPageComposite(Composite parent, int style, AnalyzersSelectionPage mediator) {
58 super(parent, style);
59 this.mediator = mediator;
60 initGUI();
61 }
62
63 private void initGUI() {
64 GridLayout thisLayout = new GridLayout();
65 this.setLayout(thisLayout);
66 this.setSize(800, 600);
67
68 rootContainer = new Composite(this, SWT.NULL);
69 rootContainer.setLayout(new FillLayout());
70 GridData rootContainerLData = new GridData(SWT.FILL, SWT.FILL, true, true);
71 rootContainer.setLayoutData(rootContainerLData);
72
73 tableCreator = new ComboBoxTableCreator(mediator);
74 }
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89 public void createTable(RawTabularData data) {
90 DataTypeInfo[] dataTypes = mediator.getDataTypesInfos();
91 String[] dataTypeNames = new String[dataTypes.length];
92
93 for (int i = 0; i < dataTypes.length; i++) {
94 dataTypeNames[i] = dataTypes[i].getName();
95 }
96
97 tableCreator.createTable(rootContainer, dataTypeNames, dataTypes, data);
98
99 rootContainer.layout();
100 }
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115 public List<IAnalyzer> getSelectedAnalyzers() {
116 List<Object> objects = tableCreator.getSelectedComboData();
117 List<IAnalyzer> analyzers = new LinkedList<IAnalyzer>();
118
119 if (objects == null) {
120 return null;
121 }
122
123 for (Object object : objects) {
124 analyzers.add((IAnalyzer)object);
125 }
126 return analyzers;
127 }
128
129
130 }