import com.vaadin.terminal.gwt.client.RenderInformation.Size;
import com.vaadin.terminal.gwt.client.ui.Field;
import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidget;
+import com.vaadin.terminal.gwt.client.ui.VAbstractPaintableWidgetContainer;
import com.vaadin.terminal.gwt.client.ui.VContextMenu;
import com.vaadin.terminal.gwt.client.ui.VNotification;
import com.vaadin.terminal.gwt.client.ui.VNotification.HideEvent;
// Changed invisibile <-> visible
if (wasVisible && manageCaption) {
// Must hide caption when component is hidden
- final Container parent = Util.getLayout(component);
- if (parent != null) {
- parent.updateCaption(paintable, uidl);
- }
-
+ updateCaption(paintable, uidl);
}
}
// Set captions
if (manageCaption) {
- final Container parent = Util.getLayout(component);
- if (parent != null) {
- parent.updateCaption(paintable, uidl);
- }
+ updateCaption(paintable, uidl);
}
// add error classname to components w/ error
tooltipInfo.setErrorUidl(null);
}
- // Set captions
- if (manageCaption) {
- final Container parent = Util.getLayout(component);
- if (parent != null) {
- parent.updateCaption(paintable, uidl);
- }
- }
/*
* updateComponentSize need to be after caption update so caption can be
* taken into account
return false;
}
+ @Deprecated
+ private void updateCaption(VPaintableWidget paintable, UIDL uidl) {
+ if (paintable instanceof VAbstractPaintableWidget) {
+ VPaintableWidget parent = ((VAbstractPaintableWidget) paintable)
+ .getParentPaintable();
+ if (parent instanceof VAbstractPaintableWidgetContainer) {
+ ((VPaintableWidgetContainer) parent).updateCaption(paintable,
+ uidl);
+ return;
+ }
+ }
+
+ // Old Container interface
+ // FIXME: Remove
+ Util.getLayout(paintable.getWidgetForPaintable()).updateCaption(
+ paintable, uidl);
+
+ }
+
/**
* Generates the style name for the widget based on the given primary style
* name (typically returned by Widget.getPrimaryStyleName()) and the UIDL.
import com.google.gwt.user.client.ui.Widget;
+/**
+ * @deprecated To be removed before 7.0.0
+ */
+@Deprecated
public interface Container extends VPaintableWidget {
/**
*/
public Widget getWidgetForPaintable();
+ /**
+ * Returns the parent {@link VPaintableWidgetContainer}
+ *
+ * @return
+ */
+ // FIXME: Rename to getParent()
+ // public VPaintableWidget getParentPaintable();
}
--- /dev/null
+/*
+@VaadinApache2LicenseForJavaFiles@
+ */
+
+package com.vaadin.terminal.gwt.client;
+
+import com.google.gwt.user.client.ui.HasWidgets;
+
+/**
+ * An interface used by client-side paintables whose widget is a component
+ * container (implements {@link HasWidgets}).
+ */
+public interface VPaintableWidgetContainer extends VPaintableWidget {
+
+ /**
+ * Update child components caption, description and error message.
+ *
+ * <p>
+ * Each component is responsible for maintaining its caption, description
+ * and error message. In most cases components doesn't want to do that and
+ * those elements reside outside of the component. Because of this layouts
+ * must provide service for it's childen to show those elements for them.
+ * </p>
+ *
+ * @param paintable
+ * Child component for which service is requested.
+ * @param uidl
+ * UIDL of the child component.
+ */
+ void updateCaption(VPaintableWidget paintable, UIDL uidl);
+
+ /**
+ * Returns the children for this paintable.
+ * <p>
+ * The children for this paintable are defined as all
+ * {@link VPaintableWidget}s whose parent is this
+ * {@link VPaintableWidgetContainer}.
+ * </p>
+ *
+ * @return A collection of children for this paintable. An empty collection
+ * if there are no children.
+ */
+ // public Collection<VPaintableWidget> getChildren();
+
+}
\r
import com.google.gwt.user.client.ui.Widget;\r
import com.vaadin.terminal.gwt.client.ApplicationConnection;\r
+import com.vaadin.terminal.gwt.client.VPaintableMap;\r
import com.vaadin.terminal.gwt.client.VPaintableWidget;\r
\r
public abstract class VAbstractPaintableWidget implements VPaintableWidget {\r
\r
private Widget widget;\r
private ApplicationConnection connection;\r
+ private String id;\r
\r
/* State variables */\r
- // private boolean enabled = true;\r
+ private boolean enabled = true;\r
\r
/**\r
* Default constructor\r
this.connection = connection;\r
}\r
\r
- // public boolean isEnabled() {\r
- // return enabled;\r
- // }\r
+ public boolean isEnabled() {\r
+ return enabled;\r
+ }\r
+\r
+ public String getId() {\r
+ return id;\r
+ }\r
+\r
+ public void setId(String id) {\r
+ this.id = id;\r
+ }\r
+\r
+ public VPaintableWidget getParentPaintable() {\r
+ // FIXME: Return VPaintableWidgetContainer\r
+ // FIXME: Store hierarchy instead of doing lookup every time\r
+\r
+ VPaintableMap paintableMap = VPaintableMap.get(getConnection());\r
+\r
+ Widget w = getWidgetForPaintable();\r
+ while (w != null) {\r
+ w = w.getParent();\r
+ if (paintableMap.isPaintable(w)) {\r
+ return paintableMap.getPaintable(w);\r
+ }\r
+ }\r
+\r
+ return null;\r
+ }\r
}\r
--- /dev/null
+/*\r
+@VaadinApache2LicenseForJavaFiles@\r
+ */\r
+package com.vaadin.terminal.gwt.client.ui;\r
+\r
+import com.vaadin.terminal.gwt.client.VPaintableWidgetContainer;\r
+\r
+public abstract class VAbstractPaintableWidgetContainer extends\r
+ VAbstractPaintableWidget implements VPaintableWidgetContainer {\r
+\r
+ /**\r
+ * Default constructor\r
+ */\r
+ public VAbstractPaintableWidgetContainer() {\r
+ }\r
+\r
+}\r