blob: 7818ac4f99f615d473a49541633efadf93e7f1f1 (
plain)
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
|
package com.vaadin.tests.minitutorials.v7a2;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.ComplexPanel;
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.TextBox;
public class MyPickerWidget extends ComplexPanel {
public static final String CLASSNAME = "mypicker";
private final TextBox textBox = new TextBox();
private final PushButton button = new PushButton("...");
public MyPickerWidget() {
setElement(Document.get().createDivElement());
setStylePrimaryName(CLASSNAME);
textBox.setStylePrimaryName(CLASSNAME + "-field");
button.setStylePrimaryName(CLASSNAME + "-button");
add(textBox, getElement());
add(button, getElement());
button.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Window.alert("Calendar picker not yet supported!");
}
});
}
public void setButtonText(String buttonText, boolean adjustSpace) {
if (buttonText == null || buttonText.length() == 0) {
buttonText = "...";
}
button.setText(buttonText);
if (adjustSpace) {
adjustButtonSpace(button.getOffsetWidth());
}
}
public void adjustButtonSpace(int width) {
getElement().getStyle().setPaddingRight(width, Unit.PX);
button.getElement().getStyle().setMarginRight(-width, Unit.PX);
}
}
|