@Override protected void onRender(Element parent, int pos) { setElement(DOM.createFieldSet(), parent, pos); legend = new El(DOM.createLegend()); legend.addStyleName("x-fieldset-header"); if (checkboxToggle && collapsible) { checkbox = DOM.createInputCheck().cast(); sinkEvents(Event.ONCLICK); if (checkboxName != null) { checkbox.setAttribute("name", checkboxName); } legend.appendChild((Element) checkbox.cast()); checkbox.setDefaultChecked(!collapsed); checkbox.setChecked(!collapsed); if (GXT.isAriaEnabled()) { checkbox.setTitle("Expand " + html); } } else if (!checkboxToggle && collapsible) { collapseBtn = new ToolButton("x-tool-toggle"); collapseBtn.addListener( Events.Select, new Listener<ComponentEvent>() { public void handleEvent(ComponentEvent be) { setExpanded(!isExpanded()); } }); collapseBtn.render(legend.dom); collapseBtn.getAriaSupport().setRole("checkbox"); if (GXT.isAriaEnabled()) { collapseBtn.setTitle("Expand " + html); } ComponentHelper.setParent(this, collapseBtn); } heading = DOM.createSpan(); heading.setClassName("x-fieldset-header-text"); legend.appendChild(heading); getElement().appendChild(legend.dom); body = el().appendChild(DOM.createDiv()); if (html != null) { setHeadingHtml(html); } if (collapsed) { onCollapse(); } updateIconTitles(); if (GXT.isFocusManagerEnabled() && !getFocusSupport().isIgnore()) { el().setTabIndex(0); el().setElementAttribute("hideFocus", "true"); sinkEvents(Event.FOCUSEVENTS); } }
@Override protected void onRender(Element target, int index) { setElement(DOM.createDiv(), target, index); el().makePositionable(true); super.onRender(target, index); ul = new El(DOM.createDiv()); ul.addStyleName(baseStyle + "-list"); getElement().appendChild(ul.dom); // add menu to ignore list eventPreview.getIgnoreList().add(getElement()); el().setTabIndex(0); el().setElementAttribute("hideFocus", "true"); el().addStyleName("x-ignore"); if (GXT.isAriaEnabled()) { Accessibility.setRole(getElement(), "menu"); Accessibility.setRole(ul.dom, "presentation"); handleRadioGroups(); } if (plain) { addStyleName("x-menu-plain"); } if (!showSeparator) { addStyleName("x-menu-nosep"); } sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS | Event.KEYEVENTS | Event.ONMOUSEWHEEL); }
@Override protected void onRemove(Component item) { super.onRemove(item); if (rendered && GXT.isAriaEnabled() && item instanceof CheckMenuItem) { handleRadioGroups(); } }
@Override protected void onHide() { super.onHide(); if (GXT.isAriaEnabled()) { Accessibility.setState(getElement(), "aria-hidden", "true"); } }
@Override protected void onRender(Element parent, int pos) { super.onRender(parent, pos); el().makePositionable(true); if (manager == null) { manager = WindowManager.get(); } if (plain) { addStyleName("x-window-plain"); } eventPreview = new BaseEventPreview() { @Override protected boolean onAutoHide(PreviewEvent ce) { if (autoHide) { if (resizing) { return false; } hide(); return true; } return false; } @Override protected void onPreviewKeyPress(PreviewEvent pe) { WindowEvent we = new WindowEvent(Window.this, pe.getEvent()); onKeyPress(we); } }; eventPreview.getIgnoreList().add(getElement()); sinkEvents(Event.ONMOUSEDOWN | Event.ONKEYPRESS); el().setTabIndex(0); el().setElementAttribute("hideFocus", "true"); if (GXT.isAriaEnabled()) { Accessibility.setRole(getElement(), "alertdialog"); Accessibility.setState(getElement(), "aria-labelledby", head.getId() + "-label"); Accessibility.setState(getElement(), "aria-hidden", "true"); } if (modal || maximizable || constrain) { monitorWindowResize = true; } if (super.width == null) { setWidth(Math.max(initialWidth, minWidth)); } }
@Override protected void onRender(Element parent, int index) { super.onRender(parent, index); if (autoLoad != null) { el().load(autoLoad); } if (GXT.isAriaEnabled()) { Accessibility.setRole(getElement(), Accessibility.ROLE_TABPANEL); } }
protected void onRender(Element target, int index) { if (template == null) { if (buttonTemplate == null) { StringBuffer sb = new StringBuffer(); sb.append( "<table cellspacing=\"0\" class=\"x-btn\" role=\"presentation\"><tbody class=\"{2}\" >"); sb.append( "<tr><td class=\"x-btn-tl\"><i> </i></td><td class=\"x-btn-tc\"></td><td class=\"x-btn-tr\"><i> </i></td></tr>"); sb.append( "<tr><td class=\"x-btn-ml\"><i> </i></td><td class=\"x-btn-mc\"><em class=\"{3}\" unselectable=\"on\"><button class=\"x-btn-text\" type=\"{1}\">{0}</button></em></td><td class=\"x-btn-mr\"><i> </i></td></tr>"); sb.append( "<tr><td class=\"x-btn-bl\"><i> </i></td><td class=\"x-btn-bc\"></td><td class=\"x-btn-br\"><i> </i></td></tr>"); sb.append("</tbody></table>"); buttonTemplate = new Template(sb.toString()); } template = buttonTemplate; } setElement( template.create( (text != null && text.length() > 0) ? text : " ", getType(), "x-btn-" + scale.name().toLowerCase() + " x-btn-icon-" + scale.name().toLowerCase() + "-" + iconAlign.name().toLowerCase(), getMenuClass()), target, index); super.onRender(target, index); buttonEl = el().selectNode(buttonSelector); buttonEl.makePositionable(); if (getFocusEl() != null) { getFocusEl().addEventsSunk(Event.FOCUSEVENTS); } preview.getIgnoreList().add(getElement()); buttonEl.setTabIndex(0); if (GXT.isAriaEnabled()) { Accessibility.setRole(buttonEl.dom, Accessibility.ROLE_BUTTON); if (menu != null) { Accessibility.setState(buttonEl.dom, "aria-haspopup", "true"); } } sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS | Event.FOCUSEVENTS); }
protected void updateIconTitles() { if (GXT.isAriaEnabled()) { String txt = "Expand " + html; if (checkbox != null) { checkbox.setTitle(txt); } if (collapseBtn != null) { collapseBtn.setTitle(txt); collapseBtn.getAriaSupport().setState("aria-checked", !collapsed ? "true" : "false"); } } }
protected void onKeyPress(WindowEvent we) { int keyCode = we.getKeyCode(); boolean t = getElement() .isOrHasChild( (com.google.gwt.dom.client.Element) we.getEvent().getEventTarget().cast()); boolean key = GXT.isFocusManagerEnabled() ? we.isShiftKey() : true; if (key && closable && onEsc && keyCode == KeyCodes.KEY_ESCAPE && t) { hide(); } if (GXT.isAriaEnabled()) { if (we.getTarget() == moveBtn.getElement()) { Point p = getPosition(true); switch (we.getKeyCode()) { case KeyCodes.KEY_LEFT: setPosition(p.x - ariaMoveResizeDistance, p.y); break; case KeyCodes.KEY_RIGHT: setPosition(p.x + ariaMoveResizeDistance, p.y); break; case KeyCodes.KEY_DOWN: setPosition(p.x, p.y + ariaMoveResizeDistance); break; case KeyCodes.KEY_UP: setPosition(p.x, p.y - ariaMoveResizeDistance); break; } } else if (we.getTarget() == resizeBtn.getElement()) { if (!resizable) { return; } Size s = getSize(); switch (we.getKeyCode()) { case KeyCodes.KEY_LEFT: setSize(s.width - ariaMoveResizeDistance, s.height); break; case KeyCodes.KEY_RIGHT: setSize(s.width + ariaMoveResizeDistance, s.height); break; case KeyCodes.KEY_DOWN: setSize(s.width, s.height + ariaMoveResizeDistance); break; case KeyCodes.KEY_UP: setSize(s.width, s.height - ariaMoveResizeDistance); break; } } } }
protected void afterShow() { hidden = false; // layout early to render window's content for size calcs if (!layoutExecuted || isLayoutNeeded()) { layout(); } if (restorePos != null) { setPosition(restorePos.x, restorePos.y); if (restoreSize != null) { setSize(restoreSize.width, restoreSize.height); } } if (restoreWindowScrolling != null) { com.google.gwt.dom.client.Document.get().enableScrolling(false); } int h = getHeight(); int w = getWidth(); if (h < minHeight && w < minWidth) { setSize(minWidth, minHeight); } else if (h < minHeight) { setHeight(minHeight); } else if (w < minWidth) { setWidth(minWidth); } // not positioned, then center if (!positioned) { el().center(true); } el().updateZIndex(0); if (modal) { modalPreview = Event.addNativePreviewHandler( new NativePreviewHandler() { public void onPreviewNativeEvent(NativePreviewEvent event) { if (Element.is(event.getNativeEvent().getEventTarget())) { Element target = (Element) Element.as(event.getNativeEvent().getEventTarget()); String tag = target.getTagName(); // ignore html and body because of frames if (!resizing && !dragging && !tag.equalsIgnoreCase("html") && !tag.equalsIgnoreCase("body") && event.getTypeInt() != Event.ONLOAD && manager.getActive() == Window.this && (modalPanel == null || (modalPanel != null && !modalPanel.getElement().isOrHasChild(target))) && !Window.this.getElement().isOrHasChild(target) && fly(target).findParent(".x-ignore", -1) == null) { ArrayList<Component> col = new ArrayList<Component>(ComponentManager.get().getAll()); for (Component c : col) { if (c instanceof TriggerField<?>) { triggerBlur((TriggerField<?>) c); } else if (c instanceof Menu) { ((Menu) c).hide(true); } } Window.this.focus(); } } } private native void triggerBlur(TriggerField<?> field) /*-{ [email protected]::triggerBlur(Lcom/extjs/gxt/ui/client/event/ComponentEvent;)(null); }-*/; }); } // missing cursor workaround if (GXT.isGecko) { El e = el().selectNode(".x-window-bwrap"); if (e != null) { e.dom.getStyle().setProperty("overflow", "auto"); e.dom.getStyle().setProperty("position", "static"); } } eventPreview.add(); if (maximized) { maximize(); } removeStyleName(HideMode.VISIBILITY.value()); if (GXT.isAriaEnabled()) { Accessibility.setState(getElement(), "aria-hidden", "false"); } fireEvent(Events.Show, new WindowEvent(this)); toFront(); }
protected void initTools() { super.initTools(); if (GXT.isAriaEnabled()) { moveBtn = new ToolButton("x-tool-move"); moveBtn.getAriaSupport().setLabel(GXT.MESSAGES.window_ariaMove()); moveBtn.getAriaSupport().setDescription(GXT.MESSAGES.window_ariaMoveDescription()); head.addTool(moveBtn); resizeBtn = new ToolButton("x-tool-resize"); resizeBtn.getAriaSupport().setLabel(GXT.MESSAGES.window_ariaResize()); resizeBtn.getAriaSupport().setDescription(GXT.MESSAGES.window_ariaResizeDescription()); head.addTool(resizeBtn); } if (minimizable) { minBtn = new ToolButton("x-tool-minimize"); minBtn.addSelectionListener( new SelectionListener<IconButtonEvent>() { public void componentSelected(IconButtonEvent ce) { minimize(); } }); head.addTool(minBtn); } if (maximizable) { maxBtn = new ToolButton("x-tool-maximize"); maxBtn.addSelectionListener( new SelectionListener<IconButtonEvent>() { public void componentSelected(IconButtonEvent ce) { maximize(); } }); head.addTool(maxBtn); restoreBtn = new ToolButton("x-tool-restore"); restoreBtn.setVisible(false); restoreBtn.addSelectionListener( new SelectionListener<IconButtonEvent>() { public void componentSelected(IconButtonEvent ce) { restore(); } }); head.addTool(restoreBtn); } if (closable) { closeBtn = new ToolButton("x-tool-close"); if (GXT.isAriaEnabled()) { closeBtn.setTitle(GXT.MESSAGES.messageBox_close()); } closeBtn.addListener( Events.Select, new Listener<ComponentEvent>() { public void handleEvent(ComponentEvent ce) { hide(); } }); head.addTool(closeBtn); } }
@Override protected boolean validateValue(String value) { // validator should run after super rules Validator tv = validator; validator = null; if (!super.validateValue(value)) { validator = tv; return false; } validator = tv; if (value.length() < 1) { // if it's blank and textfield didn't flag it then // its valid it's valid return true; } String v = value; Number d = null; try { d = getPropertyEditor().convertStringValue(v); } catch (Exception e) { String error = ""; if (getMessages().getNanText() == null) { error = GXT.MESSAGES.numberField_nanText(v); } else { error = Format.substitute(getMessages().getNanText(), v); } markInvalid(error); return false; } if (d.doubleValue() < minValue.doubleValue()) { String error = ""; if (getMessages().getMinText() == null) { error = GXT.MESSAGES.numberField_minText(minValue.doubleValue()); } else { error = Format.substitute(getMessages().getMinText(), minValue); } markInvalid(error); return false; } if (d.doubleValue() > maxValue.doubleValue()) { String error = ""; if (getMessages().getMaxText() == null) { error = GXT.MESSAGES.numberField_maxText(maxValue.doubleValue()); } else { error = Format.substitute(getMessages().getMaxText(), maxValue); } markInvalid(error); return false; } if (!allowNegative && d.doubleValue() < 0) { markInvalid(getMessages().getNegativeText()); return false; } if (validator != null) { String msg = validator.validate(this, value); if (msg != null) { markInvalid(msg); return false; } } if (GXT.isAriaEnabled()) { getInputEl().dom.setAttribute("aria-valuenow", "" + value); } return true; }