private Element headerText;
- private boolean readonly;
+ private boolean closable = true;
boolean dynamicWidth = false;
boolean dynamicHeight = false;
immediate = uidl.hasAttribute("immediate");
- if (isReadOnly() != uidl.getBooleanAttribute("readonly")) {
- setReadOnly(!isReadOnly());
- }
+ setClosable(!uidl.getBooleanAttribute("readonly"));
// Initialize the position form UIDL
try {
}
- private void setReadOnly(boolean readonly) {
- this.readonly = readonly;
- if (readonly) {
- DOM.setStyleAttribute(closeBox, "display", "none");
- } else {
+ /**
+ * Sets the closable state of the window. Additionally hides/shows the close
+ * button according to the new state.
+ *
+ * @param closable
+ * true if the window can be closed by the user
+ */
+ protected void setClosable(boolean closable) {
+ if (this.closable == closable) {
+ return;
+ }
+
+ this.closable = closable;
+ if (closable) {
DOM.setStyleAttribute(closeBox, "display", "");
+ } else {
+ DOM.setStyleAttribute(closeBox, "display", "none");
}
+
}
- private boolean isReadOnly() {
- return readonly;
+ /**
+ * Returns the closable state of the sub window. If the sub window is
+ * closable a decoration (typically an X) is shown to the user. By clicking
+ * on the X the user can close the window.
+ *
+ * @return true if the sub window is closable
+ */
+ protected boolean isClosable() {
+ return closable;
}
@Override
onResizeEvent(event);
event.cancelBubble(true);
} else if (target == closeBox) {
- if (type == Event.ONCLICK) {
+ if (type == Event.ONCLICK && isClosable()) {
onCloseClick();
event.cancelBubble(true);
}
setPositionY(y < 0 ? -1 : y);
}
- if (!isReadOnly()) {
+ if (isClosable()) {
// Closing
final Boolean close = (Boolean) variables.get("close");
if (close != null && close.booleanValue()) {
requestRepaint();
}
+
+ /**
+ * Returns the closable status of the sub window. If a sub window is
+ * closable it typically shows an X in the upper right corner. Clicking on
+ * the X sends a close event to the server. Setting closable to false will
+ * remove the X from the sub window and prevent the user from closing the
+ * window.
+ *
+ * Note! For historical reasons readonly controls the closability of the sub
+ * window and therefore readonly and closable affect each other. Setting
+ * readonly to true will set closable to false and vice versa.
+ *
+ * Closable only applies to sub windows, not to browser level windows.
+ *
+ * @return true if the sub window can be closed by the user.
+ */
+ public boolean isClosable() {
+ return !isReadOnly();
+ }
+
+ /**
+ * Set the closable status for the sub window. If a sub window is closable
+ * it typically shows an X in the upper right corner. Clicking on the X
+ * sends a close event to the server. Setting closable to false will remove
+ * the X from the sub window and prevent the user from closing the window.
+ *
+ * Note! For historical reasons readonly controls the closability of the sub
+ * window and therefore readonly and closable affect each other. Setting
+ * readonly to true will set closable to false and vice versa.
+ *
+ * Closable only applies to sub windows, not to browser level windows.
+ *
+ * @param closable
+ * determines if the sub window can be closed by the user.
+ */
+ public void setClosable(boolean closable) {
+ setReadOnly(!closable);
+ }
+
}