1 |
|
package org.kuali.student.common.ui.client.widgets.table.scroll; |
2 |
|
|
3 |
|
import com.google.gwt.event.dom.client.BlurEvent; |
4 |
|
import com.google.gwt.event.dom.client.BlurHandler; |
5 |
|
import com.google.gwt.event.dom.client.ChangeEvent; |
6 |
|
import com.google.gwt.event.dom.client.ChangeHandler; |
7 |
|
import com.google.gwt.event.dom.client.ClickEvent; |
8 |
|
import com.google.gwt.event.dom.client.ClickHandler; |
9 |
|
import com.google.gwt.event.dom.client.HasChangeHandlers; |
10 |
|
import com.google.gwt.event.dom.client.HasClickHandlers; |
11 |
|
import com.google.gwt.event.shared.HandlerRegistration; |
12 |
|
import com.google.gwt.user.client.ui.HasText; |
13 |
|
import com.google.gwt.user.client.ui.Label; |
14 |
|
import com.google.gwt.user.client.ui.SimplePanel; |
15 |
|
import com.google.gwt.user.client.ui.TextBox; |
16 |
|
|
|
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 9 |
Complexity Density: 0.43 |
|
17 |
|
public class EditableLabel extends SimplePanel implements HasClickHandlers, HasText, HasChangeHandlers { |
18 |
|
Label label = new Label(); |
19 |
|
TextBox textBox = new TextBox(); |
20 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
21 |
0
|
public EditableLabel() {... |
22 |
0
|
super.setWidget(label); |
23 |
0
|
textBox.addChangeHandler(new ChangeHandler() { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
24 |
0
|
@Override... |
25 |
|
public void onChange(ChangeEvent event) { |
26 |
0
|
label.setText(textBox.getText()); |
27 |
|
} |
28 |
|
}); |
29 |
0
|
textBox.addClickHandler(new ClickHandler(){ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
30 |
0
|
@Override... |
31 |
|
public void onClick(ClickEvent event) { |
32 |
0
|
event.stopPropagation(); |
33 |
|
} |
34 |
|
|
35 |
|
}); |
36 |
0
|
textBox.addBlurHandler(new BlurHandler() { |
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
37 |
0
|
@Override... |
38 |
|
public void onBlur(BlurEvent event) { |
39 |
0
|
label.setText(textBox.getText()); |
40 |
0
|
EditableLabel.this.setWidget(label); |
41 |
|
|
42 |
|
} |
43 |
|
}); |
44 |
0
|
label.addClickHandler(new ClickHandler() { |
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
45 |
0
|
@Override... |
46 |
|
public void onClick(ClickEvent event) { |
47 |
0
|
textBox.setText(label.getText()); |
48 |
0
|
int width = label.getOffsetWidth(); |
49 |
0
|
int height = label.getOffsetHeight()+3; |
50 |
0
|
EditableLabel.this.setWidget(textBox); |
51 |
0
|
textBox.setWidth(""+width+"px"); |
52 |
0
|
textBox.setHeight(""+height+"px"); |
53 |
0
|
textBox.selectAll(); |
54 |
0
|
textBox.setFocus(true); |
55 |
|
} |
56 |
|
}); |
57 |
|
} |
58 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
59 |
0
|
@Override... |
60 |
|
public String getText() { |
61 |
0
|
return label.getText(); |
62 |
|
|
63 |
|
} |
64 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
65 |
0
|
@Override... |
66 |
|
public void setText(String text) { |
67 |
0
|
label.setText(text); |
68 |
|
} |
69 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
0
|
@Override... |
71 |
|
public HandlerRegistration addChangeHandler(ChangeHandler handler) { |
72 |
0
|
return textBox.addChangeHandler(handler); |
73 |
|
} |
74 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
75 |
0
|
@Override... |
76 |
|
public HandlerRegistration addClickHandler(ClickHandler handler) { |
77 |
0
|
return label.addClickHandler(handler); |
78 |
|
} |
79 |
|
} |