/** Test an event that supports shift keys by testing each shift key individually. */ private void testTriggerEventWithShiftKeys( BubbleAssertingEventListener listener, EventCreator creator) { Event.setEventListener(parent, listener); Event.setEventListener(child, listener); listener.setExpectedShiftKeys(true, true, true, true); child.dispatchEvent(creator.createEvent(true, true, true, true)); listener.assertReceived(); listener.setExpectedShiftKeys(true, false, false, false); child.dispatchEvent(creator.createEvent(true, false, false, false)); listener.assertReceived(); listener.setExpectedShiftKeys(false, true, false, false); child.dispatchEvent(creator.createEvent(false, true, false, false)); listener.assertReceived(); listener.setExpectedShiftKeys(false, false, true, false); child.dispatchEvent(creator.createEvent(false, false, true, false)); listener.assertReceived(); listener.setExpectedShiftKeys(false, false, false, true); child.dispatchEvent(creator.createEvent(false, false, false, true)); listener.assertReceived(); }
@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); } }
protected void onClick(ComponentEvent ce) { if (checkboxToggle && ce.getTarget() == (Element) checkbox.cast()) { setExpanded(!isExpanded()); boolean isExpanded = isExpanded(); checkbox.setChecked(isExpanded); checkbox.setDefaultChecked(isExpanded); } }
@Test public void checkCreateImageInputElement() { // Test InputElement e = d.createImageInputElement(); // Assert Assert.assertEquals("image", e.getType()); }
@Test public void checkCreateRadioInputElement() { // Test InputElement e = d.createRadioInputElement("test"); // Assert Assert.assertEquals("RADIO", e.getType()); Assert.assertEquals("test", e.getName()); }
/** Tests that {@link Event#getCurrentEvent()} returns the right value for synthesized events. */ public void testGetCurrentEvent() { CurrentEventListener listener = new CurrentEventListener(); Event.setEventListener(child, listener); // Test all three major event types. child.dispatchEvent(Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false)); child.dispatchEvent(Document.get().createKeyPressEvent(false, false, false, false, 65)); child.dispatchEvent(Document.get().createFocusEvent()); assertTrue("Expecting click as current event", listener.gotClick); assertTrue("Expecting keypress as current event", listener.gotKeyPress); assertTrue("Expecting focus as current event", listener.gotFocus); }
/** Tests createDblClickEvent(). */ public void testTriggerDblClickEvent() { BubbleAssertingEventListener listener = new BubbleAssertingEventListener("dblclick", true) { @Override public void onBrowserEvent(Event event) { if (cancelled) { return; } if (event.getTypeInt() == Event.ONCLICK) { // Some browsers (IE, I'm looking at you) synthesize an extra click // event when a double-click is triggered. This synthesized click // will *not* have the same properties as the dblclick, so we will // not try to assert them here. return; } super.onBrowserEvent(event); assertMouseCoordinates(event); } }; Event.setEventListener(parent, listener); Event.setEventListener(child, listener); child.dispatchEvent( Document.get() .createDblClickEvent( MOUSE_DETAIL, SCREEN_X, SCREEN_Y, CLIENT_X, CLIENT_Y, true, true, true, true)); listener.cancel(); assertTrue("Expected child to receive event", listener.childReceived); assertTrue("Expected parent to receive event", listener.parentReceived); }
private void searchFieldDisabled() { isDisabled = selectElement.isDisabled(); if (isDisabled) { container.addClass(css.chznDisabled()); InputElement.as(searchField.get(0)).setDisabled(true); if (!isMultiple) { selectedItem.unbind("focus", activateAction); } } else { container.removeClass(css.chznDisabled()); InputElement.as(searchField.get(0)).setDisabled(false); if (!isMultiple) { selectedItem.bind("focus", activateAction); } } }
@Override protected void onEnable() { super.onEnable(); if (collapseBtn != null) { collapseBtn.enable(); } else if (checkbox != null) { checkbox.setDisabled(false); } }
private void login() { final String name = elName.getValue().trim(); String pass = elPass.getValue().trim(); elPass.setValue(""); if (GWTUtils.isEmpty(name) || GWTUtils.isEmpty(pass)) { return; } new AjaxRequest(Actions.LOGIN) .addParam("name", name) .addParam("pass", pass) .send( new AjaxCallback() { @Override public void onResponse(JSONObject json) { applyLogin(name, json); } }); }
/** Tests createChangeEvent(). */ public void testTriggerChangeEvent() { BubbleAssertingEventListener listener = new BubbleAssertingEventListener("change", false); Event.setEventListener(parent, listener); Event.setEventListener(child, listener); child.dispatchEvent(Document.get().createChangeEvent()); listener.cancel(); assertTrue("Expected child to receive event", listener.childReceived); }
private void updateRange(final int value) { double val = value / 100.0; String css = "background-image: -webkit-gradient(linear, 0% 0%, 100% 0%, color-stop(" + val + ", rgb(114, 171, 14)), color-stop(" + val + ", rgb(197, 197, 197)));"; range.setAttribute("style", css); }
/** Creates the underlying file input. */ private void createFileInput() { if (file != null) { el().removeChild(file.dom); } final InputElement fileElement = Document.get().createFileInputElement(); file = new El((Element) fileElement.cast()); file.addEventsSunk(Event.ONCHANGE | Event.FOCUSEVENTS); file.setId(XDOM.getUniqueId()); file.addStyleName("x-form-file"); file.setTabIndex(-1); getFileInput().setName(name); getFileInput().setAccept(accept); file.insertInto(getElement(), 1); if (file != null) { file.setEnabled(isEnabled()); } }
@Override protected void onFocus(ComponentEvent ce) { super.onFocus(ce); if (GXT.isFocusManagerEnabled()) { if (checkboxToggle && checkbox != null) { checkbox.focus(); } else if (collapseBtn != null) { collapseBtn.focus(); } } }
private void applyLogin(String name, JSONObject json) { JSONObject jsonObj = JSONHelper.getObject(json, "data"); boolean found = JSONHelper.getPrimitiveBoolean(jsonObj, "found", false); if (!found) { Window.alert("Пользователь " + GWTUtils.safeString(name) + " не найден!"); } else { elName.setValue(""); setCurrentUser(name); Window.Location.reload(); } }
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"); } } }
/** Shows in a popup, and returns the popup. */ public UniversalPopup showInPopup() { PopupChrome chrome = PopupChromeFactory.createPopupChrome(); UniversalPopup popup = PopupFactory.createPopup(null, new CenterPopupPositioner(), chrome, true); TitleBar titleBar = popup.getTitleBar(); titleBar.setTitleText("Select Gadget"); popup.add(GadgetSelectorWidget.this); popup.show(); gadgetUrl.focus(); return popup; }
public List<String> getFilenames() { ArrayList<String> result = new ArrayList<String>(); JavaScriptObject rawFileList = getElement().getPropertyJSO("files"); if (rawFileList == null) { result.add(InputElement.as(getElement()).getValue()); // IE does not support multiple-select } else { FileList fileList = rawFileList.cast(); for (int i = 0; i < fileList.getLength(); ++i) { result.add(fileList.item(i).getName()); } } return result; }
protected void onExpand() { collapsed = false; if (checkboxToggle && checkbox != null) { checkbox.setChecked(true); } body.setVisible(true); removeStyleName("x-panel-collapsed"); for (Component c : getItems()) { if (!isComponentHidden(c) && c.isRendered()) { doNotify(c, true); } } updateIconTitles(); FieldSetEvent fe = new FieldSetEvent(this); fireEvent(Events.Expand, fe); }
/** Tests createFocusEvent(). */ public void testTriggerFocusEvent() { NonBubbleAssertingEventListener listener = new NonBubbleAssertingEventListener("focus") { @Override public void onBrowserEvent(Event event) { if (cancelled) { return; } super.onBrowserEvent(event); assertEquals("focus", event.getType()); } }; Event.setEventListener(parent, listener); Event.setEventListener(child, listener); child.dispatchEvent(Document.get().createFocusEvent()); listener.cancel(); assertTrue("Expected child to receive event", listener.childReceived); }
/** * Tests createKeyPressEvent(). * * <p>Failed in all modes due to HtmlUnit bug: */ @DoNotRunWith({Platform.HtmlUnitBug}) public void testTriggerScrollEvent() { NonBubbleAssertingEventListener listener = new NonBubbleAssertingEventListener("scroll") { @Override public void onBrowserEvent(Event event) { if (cancelled) { return; } super.onBrowserEvent(event); assertEquals("scroll", event.getType()); } }; Event.setEventListener(parent, listener); Event.setEventListener(child, listener); child.dispatchEvent(Document.get().createScrollEvent()); listener.cancel(); assertTrue("Expected child to receive event", listener.childReceived); }
public QCheckBox(Element elem, String displaynamePosition) { inputElem = (InputElement) this.getElement().getChild(0); labelElem = (LabelElement) this.getElement().getChild(1); if (displaynamePosition.equals(DISPLAYNAME_POSITION_LEFT)) { getElement().appendChild(labelElem); getElement().appendChild(inputElem); } else { getElement().appendChild(inputElem); getElement().appendChild(labelElem); } String uid = DOM.createUniqueId(); inputElem.setPropertyString("id", uid); labelElem.setHtmlFor(uid); directionalTextHelper = new DirectionalTextHelper(labelElem, true); // Accessibility: setting tab index to be 0 by default, ensuring element // appears in tab sequence. FocusWidget's setElement method already // calls setTabIndex, which is overridden below. However, at the time // that this call is made, inputElem has not been created. So, we have // to call setTabIndex again, once inputElem has been created. setTabIndex(0); }
/** Tests NativeEvent.stopPropagation(). */ public void testStopPropagation() { NonBubbleAssertingEventListener listener = new NonBubbleAssertingEventListener("click") { @Override public void onBrowserEvent(Event event) { super.onBrowserEvent(event); if (event.getCurrentEventTarget().equals(child)) { event.stopPropagation(); } } }; Event.setEventListener(parent, listener); Event.setEventListener(child, listener); child.dispatchEvent( Document.get() .createClickEvent( MOUSE_DETAIL, SCREEN_X, SCREEN_Y, CLIENT_X, CLIENT_Y, true, true, true, true)); listener.cancel(); assertTrue("Expected child to receive event", listener.childReceived); }
/** Tests createClickEvent(). */ public void testTriggerClickEvent() { BubbleAssertingEventListener listener = new BubbleAssertingEventListener("click", true) { @Override public void onBrowserEvent(Event event) { if (cancelled) { return; } super.onBrowserEvent(event); assertMouseCoordinates(event); } }; Event.setEventListener(parent, listener); Event.setEventListener(child, listener); child.dispatchEvent( Document.get() .createClickEvent( MOUSE_DETAIL, SCREEN_X, SCREEN_Y, CLIENT_X, CLIENT_Y, true, true, true, true)); listener.cancel(); assertTrue("Expected child to receive event", listener.childReceived); assertTrue("Expected parent to receive event", listener.parentReceived); }
public void setData(TaskDTO data) { this.task = data; name.setInnerHTML(data.getName()); endDate.setInnerHTML(data.getEndDate()); delegator.setInnerHTML(data.getDelegator()); priority.setInnerHTML(data.getPriority() + ""); percentCompleted.setInnerHTML(data.getPercentCompleted() + " %"); if (!data.getExternalId().isEmpty()) { // TODO : display edit percent completed range.getStyle().setDisplay(Style.Display.NONE); } range.setAttribute("min", "0"); range.setAttribute("max", "100"); range.setAttribute("step", "5"); range.setAttribute("value", String.valueOf(data.getPercentCompleted())); range.setDisabled(true); updateRange(data.getPercentCompleted()); }
@UiHandler("useCustom") void onClickCustom(ClickEvent event) { select(gadgetUrl.getValue()); }
/** * This constructor may be used by subclasses to explicitly use an existing element. This element * must be an <input> element whose type is 'file'. * * @param element the element to be used */ protected FileUpload(Element element) { assert InputElement.as(element).getType().equalsIgnoreCase("file"); setElement(element); }