Java Code Examples for com.google.gwt.user.client.DOM#eventGetType()

The following examples show how to use com.google.gwt.user.client.DOM#eventGetType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SessionDatesSelector.java    From unitime with Apache License 2.0 6 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	switch (DOM.eventGetType(event)) {
    case Event.ONMOUSEDOWN:
    	SelectionMode mode = null; 
    	for (SelectionMode m: SelectionMode.values())
    		if (hasUnselectedDays(m)) {
    			mode = m; break;
    		}
    	if (mode != null)
    		setAllSelected(true, mode);
    	else
    		setAllSelected(false, SelectionMode.All);
    	if (iCursor != null) iPanel.getWidget().setCursor(iCursor);
    	event.preventDefault();
    	break;
	}
	super.onBrowserEvent(event);
}
 
Example 2
Source File: CubaNotification.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onEventPreview(Event event) {
    int type = DOM.eventGetType(event);

    if ((type == Event.ONCLICK || type == Event.ONTOUCHEND)
            && event.getEventTarget() != null) {
        Element target = Element.as(event.getEventTarget());
        if (containsSubstring(target.getClassName(), CUBA_NOTIFICATION_MODALITY_CURTAIN)) {
            hide();
            return false;
        }
    }

    if (type == Event.ONKEYDOWN && event.getKeyCode() == KeyCodes.KEY_ESCAPE) {
        if (!getElement().getClassName().contains(TRAY_STYLE)) {
            hide();
            return false;
        }
    }

    return super.onEventPreview(event);
}
 
Example 3
Source File: HorizontalPanelWithHint.java    From unitime with Apache License 2.0 6 votes vote down vote up
public void onBrowserEvent(Event event) {
	int x = 10 + event.getClientX() + getElement().getOwnerDocument().getScrollLeft();
	int y = 10 + event.getClientY() + getElement().getOwnerDocument().getScrollTop();
	
	switch (DOM.eventGetType(event)) {
	case Event.ONMOUSEMOVE:
		if (iHint.isShowing()) {
			iHint.setPopupPosition(x, y);
		} else {
			iShowHint.cancel();
			iHint.setPopupPosition(x, y);
			iShowHint.schedule(1000);
		}
		break;
	case Event.ONMOUSEOUT:
		iShowHint.cancel();
		if (iHint.isShowing())
			iHideHint.schedule(1000);
		break;
	}
}
 
Example 4
Source File: TimetableGrid.java    From unitime with Apache License 2.0 6 votes vote down vote up
public void onBrowserEvent(Event event) {
	EventTarget related = event.getRelatedEventTarget();
    switch (DOM.eventGetType(event)) {
	case Event.ONCLICK:
		if (getCell().hasId() && getCell().getType() == TimetableGridCell.Type.Class) {
			UniTimeFrameDialog.openDialog(MESSAGES.dialogSuggestions(), "gwt.jsp?page=suggestions&menu=hide&id=" + getCell().getId(),"900","90%");
			select(false);
		}
		break;
	case Event.ONMOUSEOVER:
        if (related == null || !getElement().isOrHasChild((Element)related.cast())) {
			select(true);
        }
		break;
	case Event.ONMOUSEOUT:
        if (related == null || !getElement().isOrHasChild((Element)related.cast())) {
        	select(false);
        }
		break;
	}
   
    super.onBrowserEvent(event);
}
 
Example 5
Source File: ClickableHint.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	super.onBrowserEvent(event);

    if ((event.getTypeInt() & Event.KEYEVENTS) != 0) {
    	int type = DOM.eventGetType(event);
    	char keyCode = (char) event.getKeyCode();
    	switch (type) {
        case Event.ONKEYUP:
        	if (keyCode == ' ' || keyCode == '\n' || keyCode == '\r')
        		onClick();
        	break;
    	}
    }
}
 
Example 6
Source File: TravelTimes.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	switch (DOM.eventGetType(event)) {
    case Event.ONMOUSEDOWN:
    	MouseDownEvent.fireNativeEvent(event, this);
    	event.stopPropagation();
    	event.preventDefault();
    	break;
	}
}
 
Example 7
Source File: CubaTreeTableWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
    super.onBrowserEvent(event);

    final int type = DOM.eventGetType(event);
    if (type == Event.ONKEYDOWN && _delegate.shortcutHandler != null) {
        _delegate.shortcutHandler.handleKeyboardEvent(event);
    }
}
 
Example 8
Source File: InputSlider.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	super.onBrowserEvent(event);
	if (!this.isStateValid()) {
		return;
	}
	switch (DOM.eventGetType(event)) {
		case Event.ONMOUSEDOWN:
		case Event.ONTOUCHSTART:
			this.handleWidget.setFocus(true);
			this.dragHandler.onMouseDown(event);
			break;
		case Event.ONMOUSEUP:
		case Event.ONTOUCHEND:
			this.dragHandler.onMouseUp(event);
			break;
		case Event.ONMOUSEMOVE:
		case Event.ONTOUCHMOVE:
			this.dragHandler.onMouseMove(event);
			break;
		case Event.ONMOUSEWHEEL:
			if (this.handleWidget.focused) {
				this.dragHandler.onMouseWheel(event);
			}
			break;
		default:
			break;
	}
}
 
Example 9
Source File: FilterBox.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
   	Element target = DOM.eventGetTarget(event);

    switch (DOM.eventGetType(event)) {
    case Event.ONMOUSEDOWN:
    	boolean open = iFilterOpen.getElement().equals(target);
    	boolean close = iFilterClose.getElement().equals(target);
    	boolean clear = iFilterClear.getElement().equals(target);
    	boolean filter = iFilter.getElement().equals(target);
    	if (isFilterPopupShowing() || close) {
    		hideFilterPopup();
    	} else if (open) {
    		hideSuggestions();
    		showFilterPopup();
    	}
    	if (clear) {
			iFilter.setText("");
			removeAllChips();
			setAriaLabel(toAriaString());
			ValueChangeEvent.fire(FilterBox.this, getValue());
    	}
    	if (!filter) {
			event.stopPropagation();
			event.preventDefault();
	    	Scheduler.get().scheduleDeferred(new ScheduledCommand() {
				@Override
				public void execute() {
					iFilter.setFocus(true);
				}
			});
    	}
    	break;
    }
}
 
Example 10
Source File: CubaScrollTableWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
    super.onBrowserEvent(event);

    final int type = DOM.eventGetType(event);
    if (type == Event.ONKEYDOWN && _delegate.shortcutHandler != null) {
        _delegate.shortcutHandler.handleKeyboardEvent(event);
    }
}
 
Example 11
Source File: CubaGridLayoutWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
    super.onBrowserEvent(event);

    final int type = DOM.eventGetType(event);
    if (type == Event.ONKEYDOWN && shortcutHandler != null) {
        shortcutHandler.handleKeyboardEvent(event);
    }
}
 
Example 12
Source File: UniTimeTableHeader.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	switch (DOM.eventGetType(event)) {
	case Event.ONKEYPRESS:
		MenuItem item = iAccessKeys.get(Character.toLowerCase((char)event.getCharCode()));
		if (item != null) {
			event.stopPropagation();
			event.preventDefault();
			item.getScheduledCommand().execute();
		}
	}
	super.onBrowserEvent(event);
	
}
 
Example 13
Source File: CubaMaskedFieldWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
    super.onBrowserEvent(event);

    final int type = DOM.eventGetType(event);

    if (type == Event.ONKEYDOWN && shortcutHandler != null) {
        shortcutHandler.handleKeyboardEvent(event);
    }
}
 
Example 14
Source File: TimeSelector.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	switch (DOM.eventGetType(event)) {
    case Event.ONBLUR:
    	BlurEvent.fireNativeEvent(event, this);
    	break;
    case Event.ONFOCUS:
    	FocusEvent.fireNativeEvent(event, this);
    	break;
	}
	super.onBrowserEvent(event);
}
 
Example 15
Source File: EventWrapper.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
/**
 * @return The event's type
 */
public int getType() {
  return DOM.eventGetType(event);
}
 
Example 16
Source File: CubaButtonWidget.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean handleKeyboardEvents(Event event) {
    int type = DOM.eventGetType(event);
    // Synthesize clicks based on keyboard events AFTER the normal key
    // handling.
    if ((event.getTypeInt() & Event.KEYEVENTS) != 0) {
        switch (type) {
            case Event.ONKEYDOWN:
                // Button should not react on shortcuts with ENTER and SPACE
                if (isShortcut(event)
                        && (event.getKeyCode() == KeyCodes.KEY_ENTER
                        || event.getKeyCode() == KeyCodes.KEY_SPACE)) {
                    return true;
                }
                // Stop propagation when the user starts pressing a button that
                // we are handling to prevent actions from getting triggered
                if (event.getKeyCode() == KeyCodes.KEY_SPACE) {
                    isFocusing = true;
                    event.preventDefault();
                    event.stopPropagation();
                    return true;
                } else if (event.getKeyCode() == KeyCodes.KEY_ENTER) {
                    isFocusing = true;
                    event.preventDefault();
                    event.stopPropagation();
                    return true;
                }
                break;

            // CAUTION IE sometimes does not generate ONKEYPRESS for ENTER, so we override default Vaadin behavior
            case Event.ONKEYUP:
                if (isFocusing) {
                    if (event.getKeyCode() == KeyCodes.KEY_SPACE) {
                        isFocusing = false;
                        onClick();
                        event.stopPropagation();
                        event.preventDefault();
                        return true;
                    } else if (event.getKeyCode() == KeyCodes.KEY_ENTER) {
                        isFocusing = false;
                        onClick();
                        event.stopPropagation();
                        event.preventDefault();
                        return true;
                    }
                } else if (isShortcut(event)
                        && (event.getKeyCode() == KeyCodes.KEY_ENTER
                        || event.getKeyCode() == KeyCodes.KEY_SPACE)) {
                    return true;
                }
                break;
            case Event.ONKEYPRESS: {
                // Button should not react on shortcuts with ENTER and SPACE
                if (isShortcut(event)
                        && (event.getKeyCode() == KeyCodes.KEY_ENTER
                        || event.getKeyCode() == KeyCodes.KEY_SPACE)) {
                    return true;
                }
            }
        }
    }

    return false;
}
 
Example 17
Source File: EventWrapper.java    From swellrt with Apache License 2.0 4 votes vote down vote up
/**
 * @return The event's type
 */
public int getType() {
  return DOM.eventGetType(event);
}
 
Example 18
Source File: TimeGrid.java    From unitime with Apache License 2.0 4 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	if (Event.ONMOUSEMOVE == DOM.eventGetType(event) && !iSelection.isActive() && iMoving != null) {
		iMoving.onBrowserEvent(event);
		if (iMoving.iCursor != null)
			getElement().getStyle().setCursor(iMoving.iCursor);
		return;
	}

	double x = event.getClientX() - getAbsoluteLeft() + Window.getScrollLeft();
	double y = event.getClientY() - getAbsoluteTop() + Window.getScrollTop();

	int slot = 3 * Math.min(Math.max(0, (int)Math.round(4 * (y - 1 + iStart * iCellHeight) / iCellHeight)), 96);
	int day = Math.min(Math.max(0, (int)Math.floor((x - 2) / iCellWidth)), iDays.length - 1);
	int weeks = (isSingleRoom() ? iSelectedWeeks.size() : iRoomResources.size());
	int week = Math.min(Math.max(0, (int)Math.floor(weeks * (x - 2 - iCellWidth * day) / (iCellWidth - 6))), weeks - 1);
	if (iRTL) {
		day = iDays.length - day - 1;
		week = weeks - week - 1;
	}
	int dayOfWeek = iDays[day];
	int h = slot / 12;
	int m = 5 * (slot % 12);
	String time = (CONSTANTS.useAmPm() ? (h == 0 ? "12": h <= 12 ? h : h-12) : h) + ":" + (m < 10 ? "0" : "") + m + (CONSTANTS.useAmPm() ? (h <= 11 ? "a" : "p") : "");
	
	int dayInv = (iDayOfWeeks == null ? (7 + dayOfWeek - iPropertiesProvider.getFirstDayOfWeek()) % 7 : dayOfWeek);
	String text = (iDayOfWeeks == null ? CONSTANTS.longDays()[dayOfWeek] : iDayOfWeeks.get(dayOfWeek)) + " " + (isSingleRoom() ? iSelectedWeeks.get(week) : iSelectedWeeks.get(0)).getDayNames().get(dayInv) +
			" " + time + (isSingleRoom() ? "" : " " + iRoomResources.get(week).getName());
	ResourceInterface room = (isSingleRoom() ? iRoomResources.get(0) : iRoomResources.get(week));
	iPopup.setPopupPosition(event.getClientX() + Window.getScrollLeft(), event.getClientY() + Window.getScrollTop());
	
	getElement().getStyle().setCursor(Cursor.CROSSHAIR);
	
	switch (DOM.eventGetType(event)) {
	case Event.ONMOUSEDOWN:
		iSelection.setStart(dayOfWeek, slot, week);
		iSelection.setEnd(dayOfWeek, slot, week);
		iSelection.setVisible(true);
		iSelection.setActive(true);
		break;
	case Event.ONMOUSEMOVE:
		iSelection.setEnd(dayOfWeek, slot, week);
		if (!iPopup.isShowing()) iPopup.show();
		if (!room.getId().equals(iLastRoomId)) {
			RoomHint.showHint(iPopup.getElement(), room.getId(), "", (room.hasDistance() ? String.valueOf(Math.round(room.getDistance())) : ""), false);
			iLastRoomId = room.getId();
		}
		break;
	case Event.ONMOUSEUP:
		onMouseUp();
		break;
	case Event.ONMOUSEOVER:
		if (!iPopup.isShowing() && (iSelection.isActive() || iMoving == null)) iPopup.show();
		if (iSelection.isActive() && !iSelection.isVisible()) {
			iSelection.setVisible(true);					
		}
		if (!room.getId().equals(iLastRoomId)) {
			RoomHint.showHint(iPopup.getElement(), room.getId(), "", (room.hasDistance() ? String.valueOf(Math.round(room.getDistance())) : ""), false);
			iLastRoomId = room.getId();
		}
		break;
	case Event.ONMOUSEOUT:
		Element child = DOM.eventGetToElement(event);
		if (child != null && !getElement().isOrHasChild(child)) {
			if (iPopup.isShowing()) {
				iPopup.hide();
				RoomHint.hideHint(); iLastRoomId = null;
			}
			iSelection.setVisible(false);
		}
		/*
		if (iSelection.isActive() && !DOM.isOrHasChild(TimeGrid.this.getElement(), DOM.eventGetToElement(event))) {
			iSelection.setActive(false);
		}
		*/
		break;
	}
	
	iHint.setText((iSelection.isVisible() && iSelection.isActive() ? iSelection.toString() : text));
	
	event.preventDefault();
	event.stopPropagation();
}
 
Example 19
Source File: ExtendedFlexTable.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
public void onBrowserEvent(Event event) {
	int selectedRow = 0;

	if (DOM.eventGetType(event) == Event.ONDBLCLICK || DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
		Element td = getMouseEventTargetCell(event);
		if (td == null) return;
		Element tr = DOM.getParent(td);
		Element body = DOM.getParent(tr);
		selectedRow = DOM.getChildIndex(body, tr);
	}

	// Only if selectedRow >= 0, indicates a document row value and must apear menu or double click action
	if (selectedRow >= 0) {

		// When de button mouse is released
		mouseX = DOM.eventGetClientX(event);
		mouseY = DOM.eventGetClientY(event);

		// On double click not sends event to onCellClicked across super.onBrowserEvent();
		if (DOM.eventGetType(event) == Event.ONDBLCLICK) {
			// Disables the event propagation the sequence is:
			// Two time entry onCellClicked before entry on onBrowserEvent and disables the
			// Tree onCellClicked that produces inconsistence error refreshing
			DOM.eventCancelBubble(event, true);
			MessagingToolBarBox.get().messageDashboard.messageStack.proposedQueryReceived.refreshProposedQueries();

		} else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
			switch (DOM.eventGetButton(event)) {
				case Event.BUTTON_RIGHT:
					markSelectedRow(selectedRow);
					MessagingToolBarBox.get().messageDashboard.messageStack.proposedQueryReceived.menuPopup.setPopupPosition(mouseX, mouseY);
					MessagingToolBarBox.get().messageDashboard.messageStack.proposedQueryReceived.menuPopup.show();
					DOM.eventPreventDefault(event); // Prevent to fire event to browser
					break;
				default:
					break;
			}
		}
	}
	super.onBrowserEvent(event);
}
 
Example 20
Source File: ExtendedFlexTable.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
public void onBrowserEvent(Event event) {
	int selectedRow = 0;

	if (DOM.eventGetType(event) == Event.ONDBLCLICK || DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
		Element td = getMouseEventTargetCell(event);
		if (td == null) return;
		Element tr = DOM.getParent(td);
		Element body = DOM.getParent(tr);
		selectedRow = DOM.getChildIndex(body, tr);
	}

	// Only if selectedRow >= 0, indicates a document row value and must apear menu or double click action
	if (selectedRow >= 0) {

		// When de button mouse is released
		mouseX = DOM.eventGetClientX(event);
		mouseY = DOM.eventGetClientY(event);

		// On double click not sends event to onCellClicked across super.onBrowserEvent();
		if (DOM.eventGetType(event) == Event.ONDBLCLICK) {
			// Disables the event propagation the sequence is:
			// Two time entry onCellClicked before entry on onBrowserEvent and disables the
			// Tree onCellClicked that produces inconsistence error refreshing
			DOM.eventCancelBubble(event, true);
			MessagingToolBarBox.get().messageDashboard.messageStack.messageSent.refreshMessagesSent();

		} else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN) {
			switch (DOM.eventGetButton(event)) {
				case Event.BUTTON_RIGHT:
					markSelectedRow(selectedRow);
					MessagingToolBarBox.get().messageDashboard.messageStack.messageSent.menuPopup.setPopupPosition(mouseX, mouseY);
					MessagingToolBarBox.get().messageDashboard.messageStack.messageSent.menuPopup.show();
					DOM.eventPreventDefault(event); // Prevent to fire event to browser
					break;
				default:
					break;
			}
		}
	}
	super.onBrowserEvent(event);
}