-
Notifications
You must be signed in to change notification settings - Fork 4
/
RCPTT532_SetFocusInTextFieldDisablesButton.java
116 lines (75 loc) · 2.52 KB
/
RCPTT532_SetFocusInTextFieldDisablesButton.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.xored.q7.quality.mockups.issues.parts;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
import com.xored.q7.quality.mockups.issues.BaseMockupPart;
public class RCPTT532_SetFocusInTextFieldDisablesButton extends BaseMockupPart {
private Composite composite = null;
private Text text = null;
private Text text2 = null;
private Button button = null;
private Button chkBox = null;
@Override
public Control construct(Composite parent) {
// TODO Auto-generated method stub
createComposite(parent);
addButton(composite);
addCheckBox(composite);
addTextField(composite);
return null;
}
private void addButton(Composite parent) {
button = new Button (parent, SWT.PUSH);
button.setText("I'm button");
}
private void addCheckBox(Composite parent) {
chkBox = new Button (parent, SWT.CHECK);
chkBox.addSelectionListener (new SelectionListener(){
@Override
public void widgetSelected(SelectionEvent e) {
// TODO Auto-generated method stub
if (chkBox.getSelection()){
text.setEnabled(true);
text2.setText("Yes");
} else {
text.setEnabled(false);
text2.setText("No");}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// TODO Auto-generated method stub
}
});
}
private void createComposite(Composite parent) {
composite = new Composite(parent, SWT.FILL);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL)
.grab(true, true).applyTo(composite);
GridLayoutFactory.swtDefaults().numColumns(1).applyTo(composite);
}
private void addTextField(Composite parent) {
text = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.WRAP );
text.setEnabled(false);
text2 = new Text(parent, SWT.MULTI | SWT.BORDER | SWT.WRAP );
text.addFocusListener(new FocusListener(){
@Override
public void focusGained(FocusEvent e) {
// TODO Auto-generated method stub
button.setEnabled(false);
}
@Override
public void focusLost(FocusEvent e) {
// TODO Auto-generated method stub
button.setEnabled(true);
}
});
}
}