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
|
/*
@VaadinApache2LicenseForJavaFiles@
*/
package com.vaadin.terminal.gwt.client.ui;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.ui.Link;
@Component(Link.class)
public class LinkConnector extends AbstractComponentConnector {
@Override
protected boolean delegateCaptionHandling() {
return false;
}
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
// Ensure correct implementation,
// but don't let container manage caption etc.
super.updateFromUIDL(uidl, client);
if (!isRealUpdate(uidl)) {
return;
}
getWidget().client = client;
getWidget().enabled = isEnabled();
if (uidl.hasAttribute("name")) {
getWidget().target = uidl.getStringAttribute("name");
getWidget().anchor.setAttribute("target", getWidget().target);
}
if (uidl.hasAttribute("src")) {
getWidget().src = client.translateVaadinUri(uidl
.getStringAttribute("src"));
getWidget().anchor.setAttribute("href", getWidget().src);
}
if (uidl.hasAttribute("border")) {
if ("none".equals(uidl.getStringAttribute("border"))) {
getWidget().borderStyle = VLink.BORDER_STYLE_NONE;
} else {
getWidget().borderStyle = VLink.BORDER_STYLE_MINIMAL;
}
} else {
getWidget().borderStyle = VLink.BORDER_STYLE_DEFAULT;
}
getWidget().targetHeight = uidl.hasAttribute("targetHeight") ? uidl
.getIntAttribute("targetHeight") : -1;
getWidget().targetWidth = uidl.hasAttribute("targetWidth") ? uidl
.getIntAttribute("targetWidth") : -1;
// Set link caption
getWidget().captionElement.setInnerText(getState().getCaption());
// handle error
if (null != getState().getErrorMessage()) {
if (getWidget().errorIndicatorElement == null) {
getWidget().errorIndicatorElement = DOM.createDiv();
DOM.setElementProperty(getWidget().errorIndicatorElement,
"className", "v-errorindicator");
}
DOM.insertChild(getWidget().getElement(),
getWidget().errorIndicatorElement, 0);
} else if (getWidget().errorIndicatorElement != null) {
DOM.setStyleAttribute(getWidget().errorIndicatorElement, "display",
"none");
}
if (getState().getIcon() != null) {
if (getWidget().icon == null) {
getWidget().icon = new Icon(client);
getWidget().anchor.insertBefore(getWidget().icon.getElement(),
getWidget().captionElement);
}
getWidget().icon.setUri(getState().getIcon().getURL());
}
}
@Override
protected Widget createWidget() {
return GWT.create(VLink.class);
}
@Override
public VLink getWidget() {
return (VLink) super.getWidget();
}
}
|