List of usage examples for com.google.gwt.dom.client EventTarget cast
@Override
public <T extends JavascriptObjectEquivalent> T cast()
From source file:app.dnd.drag.DraggableCellDecorator.java
License:Apache License
public void onBrowserEvent(Context context, Element parent, final T value, NativeEvent event, ValueUpdater<T> valueUpdater) { if (MOUSE_DOWN.equals(event.getType())) { EventTarget eventTarget = event.getEventTarget(); if (Element.is(eventTarget)) { Element target = eventTarget.cast(); Element wrapper = target.getParentElement(); if (wrapper != null && dragHandlerClass.equals(wrapper.getClassName())) { DNDContext dndContext = dragSource.startDragging(value); dragController.dragStart(dndContext, parent); event.stopPropagation(); event.preventDefault();/*from w w w . ja va2 s . c om*/ return; } } } final Element cellParent = getCellParent(parent); cell.onBrowserEvent(context, cellParent, getValue(value), event, getValueUpdater()); }
From source file:com.gwtm.ui.client.widgets.CheckBoxGroup.java
License:Apache License
@Override public void onClick(ClickEvent e) { final EventTarget target = e.getNativeEvent().getEventTarget(); String targetTagName = ((Element) target.cast()).getTagName().toUpperCase(); Utils.Console("onClick target " + targetTagName); if (targetTagName.equals("LABEL")) { return; // if check box label is click, another (simulated) click event with // check box INPUT as target will fire after this one. So this click event // can be safely ignored. }//from w w w . j a va 2s . co m Element div = Element.as(target); while (!div.getNodeName().toUpperCase().equals("SPAN") || div.getParentElement() != this.getElement()) { div = div.getParentElement(); if (div == null) { Utils.Console("CheckBoxGroup onClick: span not found"); return; } } final int index = DOM.getChildIndex(this.getElement(), (com.google.gwt.user.client.Element) div); com.google.gwt.user.client.ui.CheckBox checkbox = (com.google.gwt.user.client.ui.CheckBox) getWidget(index); Utils.Console("onClick " + checkbox.getValue()); if (targetTagName.equals("INPUT")) { Utils.Console("onClick value changed"); checkbox.setValue(checkbox.getValue()); // if target is check box INPUT, check box value is // already changed when click event is fired. // just need to set its current value back to the check box // to update style. } else { checkbox.setValue(!checkbox.getValue()); } Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { // SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(index, target); // fireEvent(selectionChangedEvent); ValueChangeEvent.fire(CheckBoxGroup.this, index); } }); }
From source file:com.gwtm.ui.client.widgets.RadioButtonGroup.java
License:Apache License
@Override public void onClick(ClickEvent e) { EventTarget target = e.getNativeEvent().getEventTarget(); String targetTagName = ((Element) target.cast()).getTagName().toUpperCase(); if (targetTagName.equals("SPAN")) { int before = getCheckedIndex(); super.onClick(e); int after = getCheckedIndex(); Utils.Console("before " + before + " after " + after); if (after == -1) { RadioButton radio = (RadioButton) getWidget(before); if (!radio.getValue()) { // cannot un-select a radio button without selecting another one. radio.setValue(true);/*from w w w . j a va 2 s.co m*/ } } else if (before > -1) { RadioButton radio = (RadioButton) getWidget(before); radio.setValue(false); } } else if (targetTagName.equals("INPUT")) { super.onClick(e); for (int i = 0; i < getWidgetCount(); i++) { RadioButton radio = (RadioButton) getWidget(i); radio.setValue(radio.getValue()); } } }
From source file:com.gwtmobile.ui.client.widgets.CheckBoxGroup.java
License:Apache License
@Override public void onClick(ClickEvent e) { final EventTarget target = e.getNativeEvent().getEventTarget(); String targetTagName = ((Element) target.cast()).getTagName().toUpperCase(); Utils.Console("onClick target " + targetTagName); if (targetTagName.equals("LABEL")) { return; // if check box label is click, another (simulated) click event with // check box INPUT as target will fire after this one. So this click event // can be safely ignored. }/*from w ww.java 2 s.c o m*/ Element div = Element.as(target); while (!div.getNodeName().toUpperCase().equals("SPAN") || div.getParentElement() != this.getElement()) { div = div.getParentElement(); if (div == null) { Utils.Console("CheckBoxGroup onClick: span not found"); return; } } final int index = DOM.getChildIndex(this.getElement(), (com.google.gwt.user.client.Element) div); com.google.gwt.user.client.ui.CheckBox checkbox = (com.google.gwt.user.client.ui.CheckBox) getWidget(index); Utils.Console("onClick " + checkbox.getValue()); if (targetTagName.equals("INPUT")) { Utils.Console("onClick value changed"); checkbox.setValue(checkbox.getValue()); // if target is check box INPUT, check box value is // already changed when click event is fired. // just need to set its current value back to the check box // to update style. } else { checkbox.setValue(!checkbox.getValue()); } Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(index, target); fireEvent(selectionChangedEvent); } }); }
From source file:com.sencha.gxt.widget.core.client.event.XEvent.java
License:sencha.com license
/** * Returns <code>true</code> if the target of this event equals or is a child * of the given element./*from w w w .j a v a2 s . co m*/ * * @param element the element * @param toElement true to use {@link Event#getRelatedEventTarget()} * @return the within state */ public final boolean within(Element element, boolean toElement) { if (Element.is(element)) { EventTarget target = toElement ? getRelatedEventTarget() : getEventTarget(); if (Element.is(target)) { return element.isOrHasChild((Element) target.cast()); } } return false; }
From source file:com.sencha.gxt.widget.core.client.grid.GridView.java
License:sencha.com license
protected void onFocus(Event event) { EventTarget eventTarget = event.getEventTarget(); if (Element.is(eventTarget)) { final Element target = eventTarget.cast(); int rowIndex = findRowIndex(target); int columnIndex = findCellIndex(target, null); focusCell(rowIndex, columnIndex, false); }/*from w w w .j a v a 2s .c om*/ focus(); }
From source file:com.sencha.gxt.widget.core.client.menu.Menu.java
License:sencha.com license
protected void onMouseOut(Event ce) { EventTarget to = ce.getRelatedEventTarget(); if (activeItem != null && (to == null || (Element.is(to) && !activeItem.getElement().isOrHasChild(Element.as(to)))) && activeItem.shouldDeactivate(ce)) { if (to != null && Element.is(to)) { XElement xto = to.cast(); if (xto.findParent("." + CommonStyles.get().ignore(), 3) != null) { return; }//from w w w . j a va 2s. c om } deactivateActiveItem(); } }
From source file:de.swm.commons.mobile.client.widgets.CheckBoxGroup.java
License:Apache License
@Override public void onClick(ClickEvent e) { final EventTarget target = e.getNativeEvent().getEventTarget(); String targetTagName = ((Element) target.cast()).getTagName().toUpperCase(); LOGGER.info("onClick target " + targetTagName); if (targetTagName.equals("LABEL") || targetTagName.equals("IMG")) { return; // if check box label or image is clicked, another (simulated) click event with // check box INPUT as target will fire after this one. So this click event // must be ignored. }// ww w. j ava 2 s . c o m Element div = Element.as(target); while (!div.getNodeName().toUpperCase().equals("SPAN") || div.getParentElement() != this.getElement()) { div = div.getParentElement(); if (div == null) { LOGGER.info("CheckBoxGroup onClick: span not found"); return; } } final int index = DOM.getChildIndex(this.getElement(), (com.google.gwt.user.client.Element) div); com.google.gwt.user.client.ui.CheckBox checkbox = (com.google.gwt.user.client.ui.CheckBox) myFlowPanel .getWidget(index); LOGGER.info("onClick " + checkbox.getValue()); if (targetTagName.equals("INPUT")) { LOGGER.info("onClick value changed"); checkbox.setValue(checkbox.getValue()); // if target is check box INPUT, check box value is // already changed when click event is fired. // just need to set its current value back to the check box // to update style. } else { checkbox.setValue(!checkbox.getValue()); } Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(index, target); fireEvent(selectionChangedEvent); } }); }
From source file:de.swm.commons.mobile.client.widgets.GenericRadioButtonGroup.java
License:Apache License
@Override public void onClick(ClickEvent e) { if (!enabled) { return;/* ww w. j a v a2 s . co m*/ } EventTarget target = e.getNativeEvent().getEventTarget(); String targetTagName = ((Element) target.cast()).getTagName().toUpperCase(); if (targetTagName.equals("SPAN")) { int before = getCheckedIndex(); super.onClick(e); int after = getCheckedIndex(); LOGGER.info("before " + before + " after " + after); if (after == -1) { RadioButton radio = (RadioButton) getWidget(before); if (!radio.getValue()) { // cannot un-select a radio button without selecting another one. radio.setValue(true); } } else if (before > -1) { RadioButton radio = (RadioButton) getWidget(before); radio.setValue(false); } } else if (targetTagName.equals("INPUT")) { super.onClick(e); for (int i = 0; i < myFlowPanel.getWidgetCount(); i++) { RadioButton radio = (RadioButton) getWidget(i); radio.setValue(radio.getValue()); } } }
From source file:next.i.view.widgets.XCheckboxGroup.java
License:Apache License
@Override public void onClick(ClickEvent e) { final EventTarget target = e.getNativeEvent().getEventTarget(); String targetTagName = ((Element) target.cast()).getTagName().toUpperCase(); //XLog.warn("onClick target=" + target + " targetTagName=" + targetTagName); if (targetTagName.equals("LABEL")) { return; // if check box label is click, another (simulated) click event // with//from w ww . jav a 2 s .c o m // check box INPUT as target will fire after this one. So this click event // can be safely ignored. } Element div = Element.as(target); while (!div.getNodeName().toUpperCase().equals("SPAN") || div.getParentElement() != this.getElement()) { div = div.getParentElement(); if (div == null) { // XLog.info("XCheckboxGroup onClick: span not found"); return; } } final int index = DOM.getChildIndex(this.getElement(), (com.google.gwt.user.client.Element) div); CheckBox checkbox = (CheckBox) _panel.getWidget(index); // XLog.info("onClick " + checkbox.getValue()); if (targetTagName.equals("INPUT")) { // XLog.info("onClick value changed"); checkbox.setValue(checkbox.getValue()); // if target is check box INPUT, // check box value is // already changed when click event is fired. // just need to set its current value back to the check box // to update style. } else { checkbox.setValue(!checkbox.getValue()); } Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { SelectionChangedEvent selectionChangedEvent = new SelectionChangedEvent(index, target); fireEvent(selectionChangedEvent); } }); }