* Updates style names in suggestion popup to help theme building.
*/
public void updateStyleNames(UIDL uidl) {
- if (uidl.hasAttribute("style")) {
+ if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_STYLE)) {
setStyleName(CLASSNAME + "-suggestpopup");
- final String[] styles = uidl.getStringAttribute("style").split(
- " ");
+ final String[] styles = uidl.getStringAttribute(
+ VAbstractPaintableWidget.ATTRIBUTE_STYLE).split(" ");
for (int i = 0; i < styles.length; i++) {
addStyleDependentName(styles[i]);
}
public static final String ATTRIBUTE_ITEM_DESCRIPTION = VAbstractPaintableWidget.ATTRIBUTE_DESCRIPTION;
public static final String ATTRIBUTE_ITEM_ICON = VAbstractPaintableWidget.ATTRIBUTE_ICON;
public static final String ATTRIBUTE_ITEM_DISABLED = VAbstractPaintableWidget.ATTRIBUTE_DISABLED;
+ public static final String ATTRIBUTE_ITEM_STYLE = VAbstractPaintableWidget.ATTRIBUTE_STYLE;
public static final String HTML_CONTENT_ALLOWED = "usehtml";
setCheckable(false);
}
- if (uidl.hasAttribute("style")) {
- String itemStyle = uidl.getStringAttribute("style");
+ if (uidl.hasAttribute(ATTRIBUTE_ITEM_STYLE)) {
+ String itemStyle = uidl
+ .getStringAttribute(ATTRIBUTE_ITEM_STYLE);
addStyleDependentName(itemStyle);
}
iteratorStack.push(itr);
itr = item.getChildIterator();
currentMenu = new VMenuBar(true, currentMenu);
- if (uidl.hasAttribute("style")) {
- for (String style : uidl.getStringAttribute("style").split(
- " ")) {
+ // this is the top-level style that also propagates to items -
+ // any item specific styles are set above in
+ // currentItem.updateFromUIDL(item, client)
+ if (uidl.hasAttribute(VAbstractPaintableWidget.ATTRIBUTE_STYLE)) {
+ for (String style : uidl.getStringAttribute(
+ VAbstractPaintableWidget.ATTRIBUTE_STYLE)
+ .split(" ")) {
currentMenu.addStyleDependentName(style);
}
}
private ArrayList<EventListener> listeners;
private static final int TOUCH_DEVICE_IDLE_DELAY = 1000;
+ public static final String ATTRIBUTE_NOTIFICATION_STYLE = VAbstractPaintableWidget.ATTRIBUTE_STYLE;
+ public static final String ATTRIBUTE_NOTIFICATION_CAPTION = VAbstractPaintableWidget.ATTRIBUTE_CAPTION;
+ public static final String ATTRIBUTE_NOTIFICATION_MESSAGE = "message";
+ public static final String ATTRIBUTE_NOTIFICATION_ICON = VAbstractPaintableWidget.ATTRIBUTE_ICON;
+ public static final String ATTRIBUTE_NOTIFICATION_POSITION = "position";
+ public static final String ATTRIBUTE_NOTIFICATION_DELAY = "delay";
+
/**
* Default constructor. You should use GWT.create instead.
*/
boolean onlyPlainText = notification
.hasAttribute(VView.NOTIFICATION_HTML_CONTENT_NOT_ALLOWED);
String html = "";
- if (notification.hasAttribute("icon")) {
+ if (notification.hasAttribute(ATTRIBUTE_NOTIFICATION_ICON)) {
final String parsedUri = client.translateVaadinUri(notification
- .getStringAttribute("icon"));
+ .getStringAttribute(ATTRIBUTE_NOTIFICATION_ICON));
html += "<img src=\"" + Util.escapeAttribute(parsedUri) + "\" />";
}
- if (notification.hasAttribute("caption")) {
- String caption = notification.getStringAttribute("caption");
+ if (notification.hasAttribute(ATTRIBUTE_NOTIFICATION_CAPTION)) {
+ String caption = notification
+ .getStringAttribute(ATTRIBUTE_NOTIFICATION_CAPTION);
if (onlyPlainText) {
caption = Util.escapeHTML(caption);
caption = caption.replaceAll("\\n", "<br />");
}
html += "<h1>" + caption + "</h1>";
}
- if (notification.hasAttribute("message")) {
- String message = notification.getStringAttribute("message");
+ if (notification.hasAttribute(ATTRIBUTE_NOTIFICATION_MESSAGE)) {
+ String message = notification
+ .getStringAttribute(ATTRIBUTE_NOTIFICATION_MESSAGE);
if (onlyPlainText) {
message = Util.escapeHTML(message);
message = message.replaceAll("\\n", "<br />");
html += "<p>" + message + "</p>";
}
- final String style = notification.hasAttribute("style") ? notification
- .getStringAttribute("style") : null;
- final int position = notification.getIntAttribute("position");
- final int delay = notification.getIntAttribute("delay");
+ final String style = notification
+ .hasAttribute(ATTRIBUTE_NOTIFICATION_STYLE) ? notification
+ .getStringAttribute(ATTRIBUTE_NOTIFICATION_STYLE) : null;
+ final int position = notification
+ .getIntAttribute(ATTRIBUTE_NOTIFICATION_POSITION);
+ final int delay = notification
+ .getIntAttribute(ATTRIBUTE_NOTIFICATION_DELAY);
createNotification(delay).show(html, position, style);
}
public class VTreePaintable extends VAbstractPaintableWidget {
+ public static final String ATTRIBUTE_NODE_STYLE = VAbstractPaintableWidget.ATTRIBUTE_STYLE;
+ public static final String ATTRIBUTE_NODE_CAPTION = VAbstractPaintableWidget.ATTRIBUTE_CAPTION;
+ public static final String ATTRIBUTE_NODE_ICON = VAbstractPaintableWidget.ATTRIBUTE_ICON;
+
+ public static final String ATTRIBUTE_ACTION_CAPTION = VAbstractPaintableWidget.ATTRIBUTE_CAPTION;
+ public static final String ATTRIBUTE_ACTION_ICON = VAbstractPaintableWidget.ATTRIBUTE_ICON;
+
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
// Ensure correct implementation and let container manage caption
while (it.hasNext()) {
final UIDL action = (UIDL) it.next();
final String key = action.getStringAttribute("key");
- final String caption = action.getStringAttribute("caption");
+ final String caption = action
+ .getStringAttribute(ATTRIBUTE_ACTION_CAPTION);
String iconUrl = null;
- if (action.hasAttribute("icon")) {
+ if (action.hasAttribute(ATTRIBUTE_ACTION_ICON)) {
iconUrl = getConnection().translateVaadinUri(
- action.getStringAttribute("icon"));
+ action.getStringAttribute(ATTRIBUTE_ACTION_ICON));
}
getWidgetForPaintable().registerAction(key, caption, iconUrl);
}
public void updateNodeFromUIDL(TreeNode treeNode, UIDL uidl) {
String nodeKey = uidl.getStringAttribute("key");
- treeNode.setText(uidl.getStringAttribute("caption"));
+ treeNode.setText(uidl.getStringAttribute(ATTRIBUTE_NODE_CAPTION));
treeNode.key = nodeKey;
getWidgetForPaintable().registerNode(treeNode);
} else {
treeNode.addStyleName(TreeNode.CLASSNAME + "-leaf");
}
- if (uidl.hasAttribute("style")) {
- treeNode.setNodeStyleName(uidl.getStringAttribute("style"));
+ if (uidl.hasAttribute(ATTRIBUTE_NODE_STYLE)) {
+ treeNode.setNodeStyleName(uidl
+ .getStringAttribute(ATTRIBUTE_NODE_STYLE));
}
String description = uidl.getStringAttribute("descr");
getWidgetForPaintable().selectedIds.add(nodeKey);
}
- treeNode.setIcon(uidl.getStringAttribute("icon"));
+ treeNode.setIcon(uidl.getStringAttribute(ATTRIBUTE_NODE_ICON));
}
void renderChildNodes(TreeNode containerNode, Iterator<UIDL> i) {
// Caption must be set before required header size is measured. If
// the caption attribute is missing the caption should be cleared.
- getWidgetForPaintable().setCaption(
- uidl.getStringAttribute("caption"),
- uidl.getStringAttribute("icon"));
+ getWidgetForPaintable()
+ .setCaption(
+ uidl.getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_CAPTION),
+ uidl.getStringAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON));
}
getWidgetForPaintable().visibilityChangesDisabled = true;
target.addAttribute("id", item.getId());
if (item.getStyleName() != null) {
- target.addAttribute("style", item.getStyleName());
+ target.addAttribute(VMenuBar.ATTRIBUTE_ITEM_STYLE,
+ item.getStyleName());
}
if (item.isSeparator()) {
import com.vaadin.terminal.WrappedRequest;
import com.vaadin.terminal.WrappedRequest.BrowserDetails;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
+import com.vaadin.terminal.gwt.client.ui.VNotification;
import com.vaadin.terminal.gwt.client.ui.VView;
import com.vaadin.tools.ReflectTools;
import com.vaadin.ui.Window.CloseListener;
final Notification n = it.next();
target.startTag("notification");
if (n.getCaption() != null) {
- target.addAttribute("caption", n.getCaption());
+ target.addAttribute(
+ VNotification.ATTRIBUTE_NOTIFICATION_CAPTION,
+ n.getCaption());
}
if (n.getDescription() != null) {
- target.addAttribute("message", n.getDescription());
+ target.addAttribute(
+ VNotification.ATTRIBUTE_NOTIFICATION_MESSAGE,
+ n.getDescription());
}
if (n.getIcon() != null) {
- target.addAttribute("icon", n.getIcon());
+ target.addAttribute(
+ VNotification.ATTRIBUTE_NOTIFICATION_ICON,
+ n.getIcon());
}
if (!n.isHtmlContentAllowed()) {
target.addAttribute(
VView.NOTIFICATION_HTML_CONTENT_NOT_ALLOWED, true);
}
- target.addAttribute("position", n.getPosition());
- target.addAttribute("delay", n.getDelayMsec());
+ target.addAttribute(
+ VNotification.ATTRIBUTE_NOTIFICATION_POSITION,
+ n.getPosition());
+ target.addAttribute(VNotification.ATTRIBUTE_NOTIFICATION_DELAY,
+ n.getDelayMsec());
if (n.getStyleName() != null) {
- target.addAttribute("style", n.getStyleName());
+ target.addAttribute(
+ VNotification.ATTRIBUTE_NOTIFICATION_STYLE,
+ n.getStyleName());
}
target.endTag("notification");
}
target.addAttribute("closable", true);
}
+ // tab icon, caption and description, but used via
+ // VCaption.updateCaption(uidl)
final Resource icon = tab.getIcon();
if (icon != null) {
target.addAttribute(VAbstractPaintableWidget.ATTRIBUTE_ICON,
if (itemStyleGenerator != null) {
String stylename = itemStyleGenerator.getStyle(itemId);
if (stylename != null) {
- target.addAttribute("style", stylename);
+ target.addAttribute(
+ VTreePaintable.ATTRIBUTE_NODE_STYLE, stylename);
}
}
}
// Adds the attributes
- target.addAttribute("caption", getItemCaption(itemId));
+ target.addAttribute(VTreePaintable.ATTRIBUTE_NODE_CAPTION,
+ getItemCaption(itemId));
final Resource icon = getItemIcon(itemId);
if (icon != null) {
- target.addAttribute("icon", getItemIcon(itemId));
+ target.addAttribute(VTreePaintable.ATTRIBUTE_NODE_ICON,
+ getItemIcon(itemId));
}
final String key = itemIdMapper.key(itemId);
target.addAttribute("key", key);
final Action a = i.next();
target.startTag("action");
if (a.getCaption() != null) {
- target.addAttribute("caption", a.getCaption());
+ target.addAttribute(
+ VTreePaintable.ATTRIBUTE_ACTION_CAPTION,
+ a.getCaption());
}
if (a.getIcon() != null) {
- target.addAttribute("icon", a.getIcon());
+ target.addAttribute(VTreePaintable.ATTRIBUTE_ACTION_ICON,
+ a.getIcon());
}
target.addAttribute("key", actionMapper.key(a));
target.endTag("action");