-moz-border-radius: 0;
-webkit-border-radius: 0;
border-radius: 0;
- font-size: 100%;
+ font-size: 16px;
-webkit-box-shadow: 0 2px 5px rgba(0,0,0,.7);
-moz-box-shadow: 0 2px 5px rgba(0,0,0,.7);
box-shadow: 0 2px 5px rgba(0,0,0,.7);
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
- font-size: 100%;
+ font-size: 16px;
background: #c8ccd0;
font-weight: bold;
}
<when-property-is name="user.agent" value="ie8" />
</any>
</replace-with>
+
+ <replace-with class="com.vaadin.client.ui.VPopupImpl">
+ <when-type-is class="com.google.gwt.user.client.ui.impl.PopupImplMozilla" />
+ <when-property-is name="user.agent" value="gecko1_8"/>
+ </replace-with>
+
+ <replace-with class="com.vaadin.client.ui.VPopupImpl">
+ <when-type-is class="com.google.gwt.user.client.ui.impl.PopupImpl" />
+ </replace-with>
</module>
ApplicationConnection a = GWT
.create(ApplicationConnection.class);
a.init(widgetSet, appConf);
- a.start();
runningApplications.add(a);
+ a.start();
}
});
}
rpcManager = GWT.create(RpcManager.class);
layoutManager = GWT.create(LayoutManager.class);
layoutManager.setConnection(this);
+ tooltip = GWT.create(VTooltip.class);
}
public void init(WidgetSet widgetSet, ApplicationConfiguration cnf) {
initializeClientHooks();
uIConnector.init(cnf.getRootPanelId(), this);
+
+ tooltip.setOwner(uIConnector.getWidget());
+
showLoadingIndicator();
scheduleHeartbeat();
html.append(details);
html.append("</I></p>");
- VNotification n = VNotification.createNotification(1000 * 60 * 45);
+ VNotification n = VNotification.createNotification(1000 * 60 * 45,
+ uIConnector.getWidget());
n.addEventListener(new NotificationRedirect(url));
n.show(html.toString(), VNotification.CENTERED_TOP,
VNotification.STYLE_SYSTEM);
if (html.length() != 0) {
/* 45 min */
- VNotification n = VNotification
- .createNotification(1000 * 60 * 45);
+ VNotification n = VNotification.createNotification(
+ 1000 * 60 * 45, uIConnector.getWidget());
n.addEventListener(new NotificationRedirect(url));
n.show(html, VNotification.CENTERED_TOP,
VNotification.STYLE_SYSTEM);
public VContextMenu getContextMenu() {
if (contextMenu == null) {
contextMenu = new VContextMenu();
+ contextMenu.setOwner(uIConnector.getWidget());
DOM.setElementProperty(contextMenu.getElement(), "id",
"PID_VAADIN_CM");
}
/* Extended title handling */
- private final VTooltip tooltip = new VTooltip(this);
+ private final VTooltip tooltip;
private ConnectorMap connectorMap = GWT.create(ConnectorMap.class);
if (passes > 100) {
VConsole.log(LOOP_ABORT_MESSAGE);
- VNotification.createNotification(VNotification.DELAY_FOREVER)
- .show(LOOP_ABORT_MESSAGE, VNotification.CENTERED,
- "error");
+ VNotification.createNotification(VNotification.DELAY_FOREVER,
+ connection.getRootConnector().getWidget()).show(
+ LOOP_ABORT_MESSAGE, VNotification.CENTERED, "error");
break;
}
}
}
}
- private static ComponentConnector findConnectorFor(Widget widget) {
+ public static ComponentConnector findConnectorFor(Widget widget) {
List<ApplicationConnection> runningApplications = ApplicationConfiguration
.getRunningApplications();
for (ApplicationConnection applicationConnection : runningApplications) {
// If the overlay has an owner, try to find the owner's connector
VOverlay overlay = findWidget(element, VOverlay.class);
if (overlay != null && overlay.getOwner() != null) {
- return getConnectorForElement(client, RootPanel.get(), overlay
- .getOwner().getElement());
+
+ return getConnectorForElement(client, client.getRootConnector()
+ .getWidget(), overlay.getOwner().getElement());
} else {
return null;
}
e.printStackTrace();
}
try {
- VNotification.createNotification(VNotification.DELAY_FOREVER).show(
- "<h1>Uncaught client side exception</h1><br />"
+ VNotification.createNotification(VNotification.DELAY_FOREVER, null)
+ .show("<h1>Uncaught client side exception</h1><br />"
+ exceptionText, VNotification.CENTERED, "error");
} catch (Exception e2) {
// Just swallow this exception
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ui.VOverlay;
public class VErrorMessage extends FlowPanel {
public static final String CLASSNAME = "v-errormessage";
+ private Widget owner;
+
public VErrorMessage() {
super();
setStyleName(CLASSNAME);
}
+ /**
+ * Set the owner, i.e the Widget that created this {@link VErrorMessage}.
+ * The owner must be set if the {@link VErrorMessage} is created
+ * 'stand-alone' (not within a {@link VOverlay}), or theming might not work
+ * properly.
+ *
+ * @see VOverlay#setOwner(Widget)
+ * @param owner
+ * the owner (creator Widget)
+ */
+ public void setOwner(Widget owner) {
+ this.owner = owner;
+ }
+
public void updateMessage(String htmlErrorMessage) {
clear();
if (htmlErrorMessage == null || htmlErrorMessage.length() == 0) {
if (errorContainer == null) {
errorContainer = new VOverlay();
errorContainer.setWidget(this);
+ errorContainer.setOwner(owner);
}
errorContainer.setPopupPosition(
DOM.getAbsoluteLeft(indicatorElement)
private boolean closing = false;
private boolean opening = false;
- private ApplicationConnection ac;
+
// Open next tooltip faster. Disabled after 2 sec of showTooltip-silence.
private boolean justClosed = false;
- public VTooltip(ApplicationConnection client) {
+ /**
+ * Used to show tooltips; usually used via the singleton in
+ * {@link ApplicationConnection}. NOTE that #setOwner(Widget)} should be
+ * called after instantiating.
+ *
+ * @see ApplicationConnection#getVTooltip()
+ */
+ public VTooltip() {
super(false, false, true);
- ac = client;
setStyleName(CLASSNAME);
FlowPanel layout = new FlowPanel();
setWidget(layout);
*/
private boolean resolveConnector(Element element) {
+ ApplicationConnection ac = getApplicationConnection();
ComponentConnector connector = Util.getConnectorForElement(ac,
RootPanel.get(), element);
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
+import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.BrowserInfo;
+import com.vaadin.client.ComponentConnector;
+import com.vaadin.client.Util;
/**
* In Vaadin UI this Overlay should always be used for all elements that
*/
private Widget owner;
+ /*
+ * ApplicationConnection that this overlay belongs to, which is needed to
+ * create the overlay in the correct container so that the correct styles
+ * are applied. If not given, owner will be used to figure out, and as a
+ * last fallback, the overlay is created w/o container, potentially missing
+ * styles.
+ */
+ protected ApplicationConnection ac;
+
/**
* The shim iframe behind the overlay, allowing PDFs and applets to be
* covered by overlays.
return leftFix;
}
+ /*
+ * A "thread local" of sorts, set temporarily so that VOverlayImpl knows
+ * which VOverlay is using it, so that it can be attached to the correct
+ * overlay container.
+ *
+ * TODO this is a strange pattern that we should get rid of when possible.
+ */
+ protected static VOverlay current;
+
@Override
public void show() {
+ current = this;
super.show();
if (isAnimationEnabled()) {
new ResizeAnimation().run(POPUP_PANEL_ANIMATION_DURATION);
} else {
positionOrSizeUpdated(1.0);
}
+ current = null;
}
@Override
DOM.getChild(shadow, 5).getOffsetHeight());
}
+ Element container = getElement().getParentElement().cast();
// Attach to dom if not there already
if (isShadowEnabled() && !isShadowAttached()) {
- RootPanel.get().getElement().insertBefore(shadow, getElement());
+ container.insertBefore(shadow, getElement());
sinkShadowEvents();
}
if (needsShimElement() && !isShimElementAttached()) {
- RootPanel.get().getElement()
- .insertBefore(getShimElement(), getElement());
+ container.insertBefore(getShimElement(), getElement());
}
}
public void setOwner(Widget owner) {
this.owner = owner;
}
+
+ /**
+ * Get the {@link ApplicationConnection} that this overlay belongs to. If
+ * it's not set, {@link #getOwner()} is used to figure it out.
+ *
+ * @return
+ */
+ protected ApplicationConnection getApplicationConnection() {
+ if (ac != null) {
+ return ac;
+ } else if (owner != null) {
+ ComponentConnector c = Util.findConnectorFor(owner);
+ if (c != null) {
+ ac = c.getConnection();
+ }
+ return ac;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Gets the 'overlay container' element pertaining to the given
+ * {@link ApplicationConnection}. Each overlay should be created in a
+ * overlay container element, so that the correct theme and styles can be
+ * applied.
+ *
+ * @param ac
+ * @return
+ */
+ public Element getOverlayContainer() {
+ ApplicationConnection ac = getApplicationConnection();
+ if (ac == null) {
+ // could not figure out which one we belong to, styling might fail
+ return RootPanel.get().getElement();
+ } else {
+ String id = ac.getConfiguration().getRootPanelId();
+ id = id += "-overlays";
+ Element container = DOM.getElementById(id);
+ if (container == null) {
+ container = DOM.createDiv();
+ container.setId(id);
+ String styles = ac.getRootConnector().getWidget().getParent()
+ .getStyleName();
+ container.setClassName(styles);
+ RootPanel.get().getElement().appendChild(container);
+ }
+ return container;
+ }
+ }
}
--- /dev/null
+package com.vaadin.client.ui;
+
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.user.client.ui.impl.PopupImpl;
+
+public class VPopupImpl extends PopupImpl {
+
+ @Override
+ public void onShow(Element popup) {
+ // Move the overlay to the appropriate overlay container
+ Element e = VOverlay.current.getOverlayContainer();
+ e.appendChild(popup);
+
+ super.onShow(popup);
+ }
+
+}
--- /dev/null
+package com.vaadin.client.ui;
+
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.user.client.ui.impl.PopupImplMozilla;
+
+public class VPopupImplMozilla extends PopupImplMozilla {
+
+ @Override
+ public void onShow(Element popup) {
+ // Move the overlay to the appropriate overlay container
+ Element e = VOverlay.current.getOverlayContainer();
+ e.appendChild(popup);
+
+ super.onShow(popup);
+ }
+
+}
*/
SuggestionPopup() {
super(true, false, true);
+ setOwner(VFilterSelect.this);
menu = new SuggestionMenu();
setWidget(menu);
});
popup = new VOverlay(true, true, true);
+ popup.setOwner(this);
+
popup.setWidget(calendar);
popup.addCloseHandler(this);
fieldSet.appendChild(errorMessage.getElement());
fieldSet.appendChild(footerContainer);
+
+ errorMessage.setOwner(this);
}
@Override
{
setWidget(item.getSubMenu());
item.getSubMenu().onShow();
+ setOwner(MenuBar.this);
}
@Override
final int shadowSpace = 10;
popup = new VOverlay(true, false, true);
+ popup.setOwner(this);
/*
* Use parents primary style name if possible and remove the submenu
final int delay = notification
.getIntAttribute(UIConstants.ATTRIBUTE_NOTIFICATION_DELAY);
- createNotification(delay).show(html, position, style);
+ createNotification(delay, client.getRootConnector().getWidget()).show(
+ html, position, style);
}
- public static VNotification createNotification(int delayMsec) {
+ public static VNotification createNotification(int delayMsec, Widget owner) {
final VNotification notification = GWT.create(VNotification.class);
notification.delayMsec = delayMsec;
if (BrowserInfo.get().isTouchDevice()) {
}
}.schedule(notification.delayMsec + TOUCH_DEVICE_IDLE_DELAY);
}
+ notification.setOwner(owner);
return notification;
}
public CustomPopup() {
super(true, false, true); // autoHide, not modal, dropshadow
-
+ setOwner(VPopupView.this);
// Delegate popup keyboard events to the relevant handler. The
// events do not propagate automatically because the popup is
// directly attached to the RootPanel.
private final HTML feedback = new HTML("", false);
private final VOverlay feedbackPopup = new VOverlay(true, false, true) {
+ {
+ setOwner(VSlider.this);
+ }
@Override
public void show() {
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HasWidgets;
-import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.BrowserInfo;
private void showModalityCurtain() {
DOM.setStyleAttribute(getModalityCurtain(), "zIndex",
"" + (windowOrder.indexOf(this) + Z_INDEX));
- if (isShowing()) {
- RootPanel.getBodyElement().insertBefore(getModalityCurtain(),
- getElement());
- } else {
- DOM.appendChild(RootPanel.getBodyElement(), getModalityCurtain());
- }
+ getOverlayContainer().appendChild(getModalityCurtain());
}
private void hideModalityCurtain() {
- DOM.removeChild(RootPanel.getBodyElement(), modalityCurtain);
+ modalityCurtain.removeFromParent();
}
/*
* iframes (etc) do not steal event.
*/
private void showDraggingCurtain() {
- DOM.appendChild(RootPanel.getBodyElement(), getDraggingCurtain());
+ getElement().getParentElement().insertBefore(getDraggingCurtain(),
+ getElement());
}
private void hideDraggingCurtain() {
if (draggingCurtain != null) {
- DOM.removeChild(RootPanel.getBodyElement(), draggingCurtain);
+ draggingCurtain.removeFromParent();
}
}
* that iframes (etc) do not steal event.
*/
private void showResizingCurtain() {
- DOM.appendChild(RootPanel.getBodyElement(), getResizingCurtain());
+ getElement().getParentElement().insertBefore(getResizingCurtain(),
+ getElement());
}
private void hideResizingCurtain() {
if (resizingCurtain != null) {
- DOM.removeChild(RootPanel.getBodyElement(), resizingCurtain);
+ resizingCurtain.removeFromParent();
}
}
getWidget().contentPanel.getElement());
getLayoutManager().registerDependency(this, getWidget().header);
getLayoutManager().registerDependency(this, getWidget().footer);
+
+ getWidget().setOwner(getConnection().getRootConnector().getWidget());
}
@Override
final Widget passwordWidget = ((ComponentConnector) target).getWidget();
final VOverlay warning = new VOverlay();
+ warning.setOwner(passwordWidget);
warning.add(new HTML("Caps Lock is enabled!"));
passwordWidget.addDomHandler(new KeyPressHandler() {
final Widget passwordWidget = ((ComponentConnector) target).getWidget();
final VOverlay warning = new VOverlay();
+ warning.setOwner(passwordWidget);
warning.add(new HTML("Caps Lock is enabled!"));
passwordWidget.addDomHandler(new KeyPressHandler() {