.i-button-link span {
text-decoration: underline;
}
+
+.i-checkbox-error {
+ background:transparent;
+ background-color: #FFE0E0;
+}
background-color: #FFFFE0;\r
}\r
-input.i-error,\r
-.i-richtextarea.i-error iframe.gwt-RichTextArea,\r
-.i-checkbox.i-error,\r
-.i-error .i-select-option,\r
-.i-error .i-textfield,\r
-.i-error .i-datefield-calendarpanel,\r
-.i-error .i-select-select,\r
-.i-error .i-select-twincol-selections,\r
-.i-error .i-select-twincol-options,\r
-.i-error .i-slider-base {\r
+.i-checkbox-error,
+.i-select-error .i-select-option,
+.i-select-error .i-select-select,
+.i-select-error .i-select-twincol-selections,
+.i-select-error .i-select-twincol-options,
+.i-slider-error .i-slider-base {\r
background:transparent;
background-color: #FFE0E0;\r
}
margin: 0;\r
}
-.i-datefield-error .i-textfield {
+.i-datefield-error .i-textfield,
+.i-datefield-error .i-datefield-calendarpanel {
+ background:transparent;
+ background-color: #FFE0E0;
+}
+
+.i-datefield-rendererror .i-textfield {
background: #ff9999;
}
--- /dev/null
+.i-formlayout-cell .i-errorindicator {
+ width: 10px;
+ height: 16px;
+ display: block;
+ background: transparent url(../icons/16/error.png) no-repeat top right;
+}
\ No newline at end of file
border-top: 1px solid #b6bbbc;
}
+.i-filterselect-error {
+ background: transparent url(img/bg-left-filter-error.png) no-repeat;
+}
+
+.i-filterselect-error .i-filterselect-button {
+ background: transparent url(img/bg-right-filter-error.png);
+}
+
+.i-select-error .i-select-option,
+.i-select-error .i-select-select,
+.i-select-error .i-select-twincol-selections,
+.i-select-error .i-select-twincol-options {
+ background:transparent;
+ background-color: #FFE0E0;
+}
+
/* IE specific styles */
* html .i-filterselect {
}
+.i-slider-error .i-slider-base {
+ background:transparent;
+ background-color: #FFE0E0;
+}
/* IE specific styles */
.i-button-link span {
text-decoration: underline;
}
+
+.i-checkbox-error {
+ background:transparent;
+ background-color: #FFE0E0;
+}
/* Provide some extra whitespace for wrapped elements
(these elements usually need the extra space, since
they aren't even handling their own caption) */
background-color: #FFFFE0;
}
-input.i-error,
-.i-richtextarea.i-error iframe.gwt-RichTextArea,
-.i-checkbox.i-error,
-.i-error .i-select-option,
-.i-error .i-textfield,
-.i-error .i-datefield-calendarpanel,
-.i-error .i-select-select,
-.i-error .i-select-twincol-selections,
-.i-error .i-select-twincol-options,
-.i-error .i-slider-base {
+.i-checkbox-error,
+.i-select-error .i-select-option,
+.i-select-error .i-select-select,
+.i-select-error .i-select-twincol-selections,
+.i-select-error .i-select-twincol-options,
+.i-slider-error .i-slider-base {
background:transparent;
background-color: #FFE0E0;
}
margin: 0;
}
-.i-datefield-error .i-textfield {
+.i-datefield-error .i-textfield,
+.i-datefield-error .i-datefield-calendarpanel {
+ background:transparent;
+ background-color: #FFE0E0;
+}
+
+.i-datefield-rendererror .i-textfield {
background: #ff9999;
}
.i-expandlayout-lo-table {
.i-expandlayout-hspacing {
margin-left: 8px;
}
+.i-formlayout-cell .i-errorindicator {
+ width: 10px;
+ height: 16px;
+ display: block;
+ background: transparent url(icons/16/error.png) no-repeat top right;
+}
.i-Notification {
font-family: "Trebuchet MS", geneva, helvetica, arial, tahoma, verdana, sans-serif;
border-top: 1px solid #b6bbbc;
}
+.i-filterselect-error {
+ background: transparent url(select/img/bg-left-filter-error.png) no-repeat;
+}
+
+.i-filterselect-error .i-filterselect-button {
+ background: transparent url(select/img/bg-right-filter-error.png);
+}
+
+.i-select-error .i-select-option,
+.i-select-error .i-select-select,
+.i-select-error .i-select-twincol-selections,
+.i-select-error .i-select-twincol-options {
+ background:transparent;
+ background-color: #FFE0E0;
+}
+
/* IE specific styles */
* html .i-filterselect {
}
+.i-slider-error .i-slider-base {
+ background:transparent;
+ background-color: #FFE0E0;
+}
/* IE specific styles */
.i-richtextarea iframe {
border: 0;
}
+
+.i-textarea-error,
+.i-textfield-error,
+.i-richtextarea-error iframe.gwt-RichTextArea {
+ background:transparent;
+ background-color: #FFE0E0;
+}
.i-tree {
text-align: left /* Force default alignment */
}
}
.i-richtextarea iframe {
border: 0;
-}
\ No newline at end of file
+}
+
+.i-textarea-error,
+.i-textfield-error,
+.i-richtextarea-error iframe.gwt-RichTextArea {
+ background:transparent;
+ background-color: #FFE0E0;
+}
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class ApplicationConnection {
- public static final String MODIFIED_CLASSNAME = "i-modified";
- public static final String ERROR_CLASSNAME = "i-error";
+ private static final String MODIFIED_CLASSNAME = "i-modified";
+ private static final String ERROR_CLASSNAME_EXT = "-error";
public static final String VAR_RECORD_SEPARATOR = "\u001e";
}
StringBuffer styleBuf = new StringBuffer();
- String primaryName = component.getStylePrimaryName();
+ final String primaryName = component.getStylePrimaryName();
styleBuf.append(primaryName);
// first disabling and read-only status
// add error classname to components w/ error
if (uidl.hasAttribute("error")) {
styleBuf.append(" ");
- styleBuf.append(ERROR_CLASSNAME);
+ styleBuf.append(primaryName);
+ styleBuf.append(ERROR_CLASSNAME_EXT);
}
// Styles + disabled & readonly
if (captionText != null) {
DOM.setElementProperty(captionText, "title", uidl
.getStringAttribute("description"));
+ addStyleDependentName("hasdescription");
} else {
setTitle(uidl.getStringAttribute("description"));
+ removeStyleDependentName("hasdescription");
}
}
import java.util.HashMap;
import java.util.Iterator;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Element;
+import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
-import com.itmill.toolkit.terminal.gwt.client.Caption;
import com.itmill.toolkit.terminal.gwt.client.Container;
+import com.itmill.toolkit.terminal.gwt.client.ErrorMessage;
import com.itmill.toolkit.terminal.gwt.client.Paintable;
import com.itmill.toolkit.terminal.gwt.client.UIDL;
+import com.itmill.toolkit.terminal.gwt.client.Util;
/**
* Two col Layout that places caption on left col and field on right col
}
setWidget(i, 0, c);
p.updateFromUIDL(childUidl, client);
+
+ prepareCell(i, 2);
+ getCellFormatter().setStyleName(i, 2, "i-formlayout-errorcell");
+ ErrorFlag error = (ErrorFlag) getWidget(i, 2);
+ if (error == null) {
+ error = new ErrorFlag();
+ setWidget(i, 2, error);
+ }
+ error.updateFromUIDL(childUidl);
}
while (getRowCount() > i) {
c.updateCaption(uidl);
}
}
+
+ public class Caption extends HTML {
+
+ public static final String CLASSNAME = "i-caption";
+
+ private final Paintable owner;
+
+ private Element requiredFieldIndicator;
+
+ private Icon icon;
+
+ private Element captionText;
+
+ private final ApplicationConnection client;
+
+ /**
+ *
+ * @param component
+ * optional owner of caption. If not set, getOwner will
+ * return null
+ * @param client
+ */
+ public Caption(Paintable component, ApplicationConnection client) {
+ super();
+ this.client = client;
+ owner = component;
+ setStyleName(CLASSNAME);
+ }
+
+ public void updateCaption(UIDL uidl) {
+ setVisible(!uidl.getBooleanAttribute("invisible"));
+
+ setStyleName(getElement(), "i-disabled", uidl
+ .hasAttribute("disabled"));
+
+ boolean isEmpty = true;
+
+ if (uidl.hasAttribute("icon")) {
+ if (icon == null) {
+ icon = new Icon(client);
+
+ DOM.insertChild(getElement(), icon.getElement(), 0);
+ }
+ icon.setUri(uidl.getStringAttribute("icon"));
+ isEmpty = false;
+ } else {
+ if (icon != null) {
+ DOM.removeChild(getElement(), icon.getElement());
+ icon = null;
+ }
+
+ }
+
+ if (uidl.hasAttribute("caption")) {
+ if (captionText == null) {
+ captionText = DOM.createSpan();
+ DOM.insertChild(getElement(), captionText, icon == null ? 0
+ : 1);
+ }
+ String c = uidl.getStringAttribute("caption");
+ if (c == null) {
+ c = "";
+ } else {
+ isEmpty = false;
+ }
+ DOM.setInnerText(captionText, c);
+ } else {
+ // TODO should span also be removed
+ }
+
+ if (uidl.hasAttribute("description")) {
+ if (captionText != null) {
+ DOM.setElementProperty(captionText, "title", uidl
+ .getStringAttribute("description"));
+ addStyleDependentName("hasdescription");
+ } else {
+ setTitle(uidl.getStringAttribute("description"));
+ removeStyleDependentName("hasdescription");
+ }
+ }
+
+ if (uidl.getBooleanAttribute("required")) {
+ if (requiredFieldIndicator == null) {
+ requiredFieldIndicator = DOM.createSpan();
+ DOM.setInnerText(requiredFieldIndicator, "*");
+ DOM.setElementProperty(requiredFieldIndicator, "className",
+ "i-required-field-indicator");
+ DOM.appendChild(getElement(), requiredFieldIndicator);
+ }
+ } else {
+ if (requiredFieldIndicator != null) {
+ DOM.removeChild(getElement(), requiredFieldIndicator);
+ requiredFieldIndicator = null;
+ }
+ }
+
+ // Workaround for IE weirdness, sometimes returns bad height in some
+ // circumstances when Caption is empty. See #1444
+ // IE7 bugs more often. I wonder what happens when IE8 arrives...
+ if (Util.isIE()) {
+ if (isEmpty) {
+ setHeight("0px");
+ DOM.setStyleAttribute(getElement(), "overflow", "hidden");
+ } else {
+ setHeight("");
+ DOM.setStyleAttribute(getElement(), "overflow", "");
+ }
+
+ }
+
+ }
+
+ /**
+ * Returns Paintable for which this Caption belongs to.
+ *
+ * @return owner Widget
+ */
+ public Paintable getOwner() {
+ return owner;
+ }
+ }
+
+ private class ErrorFlag extends HTML {
+ private static final String CLASSNAME = ".i-form-layout-error-indicator";
+ Element errorIndicatorElement;
+ private ErrorMessage errorMessage;
+
+ public ErrorFlag() {
+ setStyleName(CLASSNAME);
+ }
+
+ public void updateFromUIDL(UIDL uidl) {
+ if (uidl.hasAttribute("error")) {
+ final UIDL errorUidl = uidl.getErrors();
+
+ if (errorIndicatorElement == null) {
+ errorIndicatorElement = DOM.createDiv();
+ if (Util.isIE()) {
+ DOM.setInnerHTML(errorIndicatorElement, " ");
+ }
+ DOM.setElementProperty(errorIndicatorElement, "className",
+ "i-errorindicator");
+ DOM.appendChild(getElement(), errorIndicatorElement);
+ }
+ if (errorMessage == null) {
+ errorMessage = new ErrorMessage();
+ }
+ errorMessage.updateFromUIDL(errorUidl);
+
+ } else if (errorIndicatorElement != null) {
+ DOM.removeChild(getElement(), errorIndicatorElement);
+ errorIndicatorElement = null;
+ }
+ }
+
+ public void onBrowserEvent(Event event) {
+ final Element target = DOM.eventGetTarget(event);
+ if (errorIndicatorElement != null
+ && DOM.compare(target, errorIndicatorElement)) {
+ switch (DOM.eventGetType(event)) {
+ case Event.ONMOUSEOVER:
+ showErrorMessage();
+ break;
+ case Event.ONMOUSEOUT:
+ hideErrorMessage();
+ break;
+ case Event.ONCLICK:
+ ApplicationConnection.getConsole().log(
+ DOM.getInnerHTML(errorMessage.getElement()));
+ default:
+ break;
+ }
+ } else {
+ super.onBrowserEvent(event);
+ }
+ }
+
+ private void hideErrorMessage() {
+ if (errorMessage != null) {
+ errorMessage.hide();
+ }
+ }
+
+ private void showErrorMessage() {
+ if (errorMessage != null) {
+ errorMessage.showAt(errorIndicatorElement);
+ }
+ }
+
+ }
}
public class ITextualDate extends IDateField implements Paintable, Field,\r
ChangeListener, ContainerResizedListener, Focusable {\r
\r
- private static final String ERROR_CLASSNAME = CLASSNAME + "-error";\r
+ private static final String PARSE_ERROR_CLASSNAME = CLASSNAME\r
+ + "-parseerror";\r
\r
private final ITextField text;\r
\r
* \r
*/\r
protected void buildDate() {\r
- removeStyleName(ERROR_CLASSNAME);\r
+ removeStyleName(PARSE_ERROR_CLASSNAME);\r
// Create the initial text for the textfield\r
String dateText;\r
if (date != null) {\r
date = DateTimeFormat.getFormat(getFormatString()).parse(\r
text.getText());\r
// remove possibly added invalid value indication\r
- removeStyleName(ERROR_CLASSNAME);\r
+ removeStyleName(PARSE_ERROR_CLASSNAME);\r
} catch (final Exception e) {\r
ApplicationConnection.getConsole().log(e.getMessage());\r
- addStyleName(ERROR_CLASSNAME);\r
+ addStyleName(PARSE_ERROR_CLASSNAME);\r
client.updateVariable(id, "lastInvalidDateString", text\r
.getText(), false);\r
date = null;\r
} else {\r
date = null;\r
// remove possibly added invalid value indication\r
- removeStyleName(ERROR_CLASSNAME);\r
+ removeStyleName(PARSE_ERROR_CLASSNAME);\r
}\r
\r
// Update variables\r