-
Notifications
You must be signed in to change notification settings - Fork 4
/
ListMockup.java
86 lines (59 loc) · 2.1 KB
/
ListMockup.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package org.eclipse.swt.list;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
import com.xored.q7.quality.mockups.issues.BaseMockupPart;
public class ListMockup extends BaseMockupPart {
@SuppressWarnings("unused")
@Override
public Control construct(Composite parent) {
// TODO Auto-generated method stub
Composite composite = new Composite(parent, SWT.NONE);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL)
.grab(true, true).applyTo(parent);
GridLayoutFactory.swtDefaults().numColumns(1).applyTo(composite);
final Text t = new Text(composite, SWT.SINGLE);
t.setText("Listening...");
Label lb = new Label(composite, SWT.NONE);
lb.setText("SINGLE List: ");
final List l1 = new List(composite, SWT.NONE);
for (int i = 0; i < 5; i++) {
l1.add("Value" + i);
}
Color red = new Color(composite.getDisplay(), new RGB(255, 0, 0));
l1.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
String string = "";
String[] selection = l1.getSelection();
for (int i = 0; i < selection.length; i++)
string += selection[i] + " ";
t.setText(string);
}
});
Label lb2 = new Label(composite, SWT.NONE);
lb2.setText("MULTI List: ");
final List l2 = new List(composite, SWT.MULTI);
for (int i = 0; i < 5; i++) {
l2.add("Item" + i);
}
l2.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
String string = "";
String[] selection = l2.getSelection();
for (int i = 0; i < selection.length; i++)
string += selection[i] + " ";
t.setText(string);
}
});
return null;
}
}