Java Code Examples for com.google.gwt.user.client.Event

The following are top voted examples for showing how to use com.google.gwt.user.client.Event. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: unitimes   File: HorizontalPanelWithHint.java   Source Code and License 8 votes vote down vote up
public HorizontalPanelWithHint(Widget hint) {
	super();
	iHint = new PopupPanel();
	iHint.setWidget(hint);
	iHint.setStyleName("unitime-PopupHint");
	sinkEvents(Event.ONMOUSEOVER);
	sinkEvents(Event.ONMOUSEOUT);
	sinkEvents(Event.ONMOUSEMOVE);
	iShowHint = new Timer() {
		@Override
		public void run() {
			iHint.show();
		}
	};
	iHideHint = new Timer() {
		@Override
		public void run() {
			iHint.hide();
		}
	};
}
 
Example 2
Project: document-management-system   File: ExtendedFlexTable.java   Source Code and License 7 votes vote down vote up
/**
 * Method originally copied from HTMLTable superclass where it was defined private
 * Now implemented differently to only return target cell if it'spart of 'this' table
 */
private Element getMouseEventTargetCell(Event event) {
	Element td = DOM.eventGetTarget(event);
	//locate enclosing td element
	while (!DOM.getElementProperty(td, "tagName").equalsIgnoreCase("td")) {
		// If we run out of elements, or run into the table itself, then give up.
		if ((td == null) || td == getElement())
			return null;
		td = DOM.getParent(td);
	}
	//test if the td is actually from this table
	Element tr = DOM.getParent(td);
	Element body = DOM.getParent(tr);
	if (body == this.getBodyElement()) {
		return td;
	}
	//Didn't find appropriate cell
	return null;
}
 
Example 3
Project: empiria.player   File: AbstractMediaScroll.java   Source Code and License 6 votes vote down vote up
@Override
public void onBrowserEvent(com.google.gwt.user.client.Event event) {
    switch (event.getTypeInt()) {
        case Event.ONMOUSEDOWN:
        case Event.ONTOUCHSTART:
            // rezerwujemy touch dla siebie nic innego nie powinno obslugiwac tego zdarzenia np TouchPageSwitch
            eventsBus.fireEvent(new PlayerEvent(PlayerEventTypes.TOUCH_EVENT_RESERVATION));
            pressed = true;
            setPosition(event);
            break;
        case Event.ONTOUCHEND:
        case Event.ONMOUSEUP:
            pressed = false;
            setPosition(event);
            break;
        case Event.ONTOUCHMOVE:
        case Event.ONMOUSEMOVE:
            setPosition(event);
        default:
            break;
    }
    super.onBrowserEvent(event);
}
 
Example 4
Project: empiria.player   File: AbstractMediaButton.java   Source Code and License 6 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
    event.preventDefault();
    int eventType = event.getTypeInt();
    switch (eventType) {
        case ONMOUSEDOWN:
        case ONTOUCHSTART:
            onClick();
            break;
        case ONMOUSEUP:
            if (!singleClick) {
                onClick();
            }
            break;
        case ONMOUSEOVER:
            onMouseOver();
            break;
        case ONTOUCHEND:
        case ONMOUSEOUT:
            onMouseOut();
            break;
    }
}
 
Example 5
Project: empiria.player   File: AccessibleCheckBox.java   Source Code and License 6 votes vote down vote up
/**
 * Replace the current input element with a new one. Preserves all state except for the name property, for nasty reasons related to radio button grouping.
 * (See implementation of {@link RadioButton#setName}.)
 *
 * @param elem the new input element
 */
protected void replaceInputElement(Element elem) {
    InputElement newInputElem = InputElement.as(elem);
    // Collect information we need to set
    int tabIndex = getTabIndex();
    boolean checked = getValue();
    boolean enabled = isEnabled();
    String formValue = getFormValue();
    String uid = inputElem.getId();
    String accessKey = inputElem.getAccessKey();
    int sunkEvents = Event.getEventsSunk(inputElem);

    // Clear out the old input element
    setEventListener(asOld(inputElem), null);

    getElement().replaceChild(newInputElem, inputElem);

    // Sink events on the new element
    Event.sinkEvents(elem, Event.getEventsSunk(inputElem));
    Event.sinkEvents(inputElem, 0);
    inputElem = newInputElem;

    // Setup the new element
    Event.sinkEvents(inputElem, sunkEvents);
    inputElem.setId(uid);
    if (!"".equals(accessKey)) {
        inputElem.setAccessKey(accessKey);
    }
    setTabIndex(tabIndex);
    setValue(checked);
    setEnabled(enabled);
    setFormValue(formValue);

    // Set the event listener
    if (isAttached()) {
        setEventListener(asOld(inputElem), this);
    }
}
 
Example 6
Project: unitimes   File: SimpleEditPage.java   Source Code and License 6 votes vote down vote up
public void onBrowserEvent(final Event event) {
	Element td = getEventTargetCell(event);
	if (td==null) return;
    final Element tr = DOM.getParent(td);
	int col = DOM.getChildIndex(tr, td);
    Element body = DOM.getParent(tr);
    int row = DOM.getChildIndex(body, tr);
    
    Widget widget = getWidget(row, col);
    if (widget != null && widget instanceof UniTimeHeaderPanel) {
    	super.onBrowserEvent(event);
    	return;
    }
    
	switch (DOM.eventGetType(event)) {
	case Event.ONMOUSEOVER:
		getRowFormatter().addStyleName(row, "hover");
		break;
	case Event.ONMOUSEOUT:
		getRowFormatter().removeStyleName(row, "hover");
		break;
	}
	
	super.onBrowserEvent(event);
}
 
Example 7
Project: unitimes   File: CurriculumProjectionRulesPage.java   Source Code and License 6 votes vote down vote up
public MyFlexTable() {
	super();
	setCellPadding(2);
	setCellSpacing(0);
	sinkEvents(Event.ONMOUSEOVER);
	sinkEvents(Event.ONMOUSEOUT);
	sinkEvents(Event.ONCLICK);
	sinkEvents(Event.ONKEYDOWN);
	setStylePrimaryName("unitime-MainTable");
	iTimer = new Timer() {
		@Override
		public void run() {
			saveOrder();
		}
	};
}
 
Example 8
Project: unitimes   File: ImageButton.java   Source Code and License 6 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	if (!isEnabled()) return;

	super.onBrowserEvent(event);

    if ((event.getTypeInt() & Event.KEYEVENTS) != 0) {
    	int type = DOM.eventGetType(event);
    	char keyCode = (char) event.getKeyCode();
    	switch (type) {
    	case Event.ONKEYDOWN:
    		if (keyCode == ' ' || keyCode == '\n' || keyCode == '\r') {
    			if (iDown != null) setResource(iDown);
    		}
    		break;
        case Event.ONKEYUP:
        	if (keyCode == ' ' || keyCode == '\n' || keyCode == '\r') {
        		setResource(iUp);
        		onClick();
        	}
        	break;
    	}
    }
}
 
Example 9
Project: unitimes   File: TimetableGrid.java   Source Code and License 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(), "suggestions.do?id=" + getCell().getId() + "&op=Reset","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 10
Project: unitimes   File: UniTimeTable.java   Source Code and License 6 votes vote down vote up
public UniTimeTable() {
	setCellPadding(2);
	setCellSpacing(0);
	sinkEvents(Event.ONMOUSEOVER);
	sinkEvents(Event.ONMOUSEOUT);
	sinkEvents(Event.ONCLICK);
	sinkEvents(Event.ONKEYDOWN);
	sinkEvents(Event.ONDBLCLICK);
	setStylePrimaryName("unitime-MainTable");
	iHintPanel = new PopupPanel();
	iHintPanel.setStyleName("unitime-PopupHint");
	Roles.getGridRole().set(getElement());
}
 
Example 11
Project: unitimes   File: HorizontalPanelWithHint.java   Source Code and License 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 12
Project: unitimes   File: TimeGrid.java   Source Code and License 6 votes vote down vote up
public SelectionLayer() {
	setStyleName("selection-layer");
	
	iPopup = new PopupPanel();
	iPopup.setStyleName("unitime-TimeGridSelectionPopup");
	iHint = new P("content");
	iPopup.setWidget(iHint);
	
	iSelection = new SelectionPanel();
	iSelection.setVisible(false);
	add(iSelection, 0, 0);
	
	sinkEvents(Event.ONMOUSEDOWN);
	sinkEvents(Event.ONMOUSEUP);
	sinkEvents(Event.ONMOUSEMOVE);
	sinkEvents(Event.ONMOUSEOVER);
	sinkEvents(Event.ONMOUSEOUT);
}
 
Example 13
Project: unitimes   File: TimeGrid.java   Source Code and License 6 votes vote down vote up
public SelectionPanel(boolean fixed) {
	setStyleName(fixed ? "selection" : "active-selection");
	if (fixed) {
		iRemove = new P("x"); iRemove.setHTML("×");
		iRemove.addMouseDownHandler(new MouseDownHandler() {
			@Override
			public void onMouseDown(MouseDownEvent event) {
				iSelections.remove(SelectionPanel.this);
				if (iSelection != null)
					iAllSelections.remove(iSelection);
			}
		});
		iRemove.getElement().getStyle().setRight(2, Unit.PX);
		iRemove.getElement().getStyle().setTop(2, Unit.PX);
		iRemove.getElement().getStyle().setPosition(Position.ABSOLUTE);
		add(iRemove);
		iText = new P("text");
		add(iText, 0, 0);
	}
	
	sinkEvents(Event.ONMOUSEDOWN);
	sinkEvents(Event.ONMOUSEUP);
	sinkEvents(Event.ONMOUSEMOVE);
}
 
Example 14
Project: unitimes   File: SessionDatesSelector.java   Source Code and License 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 15
Project: unitimes   File: InfoPanelImpl.java   Source Code and License 6 votes vote down vote up
public void onBrowserEvent(Event event) {
	if (iHint.getText().isEmpty()) return;
	iX = 10 + event.getClientX() + getElement().getOwnerDocument().getScrollLeft();
	iY = 10 + event.getClientY() + getElement().getOwnerDocument().getScrollTop();
	
	switch (DOM.eventGetType(event)) {
	case Event.ONMOUSEMOVE:
		if (iInfoPanel.isShowing()) {
			int maxX = Window.getScrollLeft() + Window.getClientWidth() - iInfoPanel.getOffsetWidth() - 10;
			iInfoPanel.setPopupPosition(Math.min(iX, maxX), iY);
		} else if (iInfo.getRowCount() > 0) {
			iShowInfo.cancel();
			iShowInfo.schedule(1000);
		}
		break;
	case Event.ONMOUSEOUT:
		iShowInfo.cancel();
		if (iInfoPanel.isShowing())
			iHideInfo.schedule(1000);
		break;
	}
}
 
Example 16
Project: appinventor-extensions   File: Icon.java   Source Code and License 6 votes vote down vote up
/**
 * Creates a new icon with the specified caption.
 *
 * @param image  image shown on icon (preferably 16 x 16px)
 * @param caption  caption shown below image
 */
public Icon(Image image, String caption) {

  panel = new VerticalPanel() {
    @Override
    public void onBrowserEvent(Event event) {
      Icon.this.onBrowserEvent(event);
    }
  };
  panel.add(image);
  panel.setCellHorizontalAlignment(image, VerticalPanel.ALIGN_CENTER);
  captionLabel = new Label(caption);
  panel.add(captionLabel);

  initWidget(panel);

  setStylePrimaryName("ode-Icon");
}
 
Example 17
Project: appinventor-extensions   File: MockComponent.java   Source Code and License 6 votes vote down vote up
/**
 * Sets the components widget representation and initializes its properties.
 *
 * <p>To be called from implementing constructor.
 *
 * @param widget  components visual representation in designer
 */
void initComponent(Widget widget) {
  // Widget needs to be initialized before the component itself so that the component properties
  // can be reflected by the widget
  initWidget(widget);

  // Capture mouse and click events in onBrowserEvent(Event)
  sinkEvents(Event.MOUSEEVENTS | Event.ONCLICK);

  // Add the special name property and set the tooltip
  String name = componentName();
  setTitle(name);
  addProperty(PROPERTY_NAME_NAME, name, null, new TextPropertyEditor());

  // TODO(user): Ensure this value is unique within the project using a list of
  // already used UUIDs
  // Set the component's UUID
  // The default value here can be anything except 0, because YoungAndroidProjectServce
  // creates forms with an initial Uuid of 0, and Properties.java doesn't encode
  // default values when it generates JSON for a component.
  addProperty(PROPERTY_NAME_UUID, "-1", null, new TextPropertyEditor());
  changeProperty(PROPERTY_NAME_UUID, "" + Random.nextInt());

  editor.getComponentPalettePanel().configureComponent(this);
}
 
Example 18
Project: appinventor-extensions   File: MockComponent.java   Source Code and License 6 votes vote down vote up
/**
 * Invoked by GWT whenever a browser event is dispatched to this component.
 */
@Override
public final void onBrowserEvent(Event event) {
  switch (event.getTypeInt()) {
    case Event.ONMOUSEDOWN:
    case Event.ONMOUSEUP:
    case Event.ONMOUSEMOVE:
    case Event.ONMOUSEOVER:
    case Event.ONMOUSEOUT:
      cancelBrowserEvent(event);
      mouseListeners.fireMouseEvent(this, event);
      break;

    case Event.ONCLICK:
      cancelBrowserEvent(event);
      select();
      break;

    default:
      // Ignore unexpected events
      break;
  }
}
 
Example 19
Project: cuba   File: CubaSideMenuWidget.java   Source Code and License 6 votes vote down vote up
public CubaSideMenuWidget() {
    setStylePrimaryName(CLASS_NAME);

    sinkEvents(Event.ONMOUSEOVER | Event.ONMOUSEOUT);

    // Navigation is only handled by the root bar
    addFocusHandler(this);
    addBlurHandler(this);

    /*
     * Firefox auto-repeat works correctly only if we use a key press
     * handler, other browsers handle it correctly when using a key down handler
     */
    if (BrowserInfo.get().isGecko()) {
        addKeyPressHandler(this);
    } else {
        addKeyDownHandler(this);
    }
}
 
Example 20
Project: vaadin-combobox-multiselect   File: VComboBoxMultiselect.java   Source Code and License 6 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	debug("VComboBoxMultiselect.SP: onBrowserEvent()");

	if (event.getTypeInt() == Event.ONCLICK) {
		final Element target = DOM.eventGetTarget(event);
		if (target == this.up || target == DOM.getChild(this.up, 0)) {
			this.lazyPageScroller.scrollUp();
		} else if (target == this.down || target == DOM.getChild(this.down, 0)) {
			this.lazyPageScroller.scrollDown();
		}

	}

	/*
	 * Prevent the keyboard focus from leaving the textfield by
	 * preventing the default behaviour of the browser. Fixes #4285.
	 */
	handleMouseDownEvent(event);
}
 
Example 21
Project: LAS   File: WindowBox.java   Source Code and License 6 votes vote down vote up
@Override
protected void onPreviewNativeEvent(NativePreviewEvent event) {
	if (this.resizable) {
		// We need to preventDefault() on mouseDown events (outside of the
		// DialogBox content) to keep text from being selected when it
		// is dragged.
		NativeEvent nativeEvent = event.getNativeEvent();

		if (!event.isCanceled()
				&& (event.getTypeInt() == Event.ONMOUSEDOWN)
				&& calcDragMode(nativeEvent.getClientX(),nativeEvent.getClientY()) >= 0) {
			nativeEvent.preventDefault();
		}
	}
	
	super.onPreviewNativeEvent(event);
}
 
Example 22
Project: document-management-system   File: ExtendedScrollTable.java   Source Code and License 6 votes vote down vote up
/**
 * ExtendedScrollTable
 */
public ExtendedScrollTable(FixedWidthGrid dataTable, FixedWidthFlexTable headerTable,
                           ScrollTableImages scrollTableImages) {
	super(dataTable, headerTable, scrollTableImages);
	this.dataTable = dataTable;
	this.headerTable = headerTable;

	dataTable.setSelectionPolicy(SelectionGrid.SelectionPolicy.ONE_ROW);
	setResizePolicy(ResizePolicy.UNCONSTRAINED);
	setScrollPolicy(ScrollPolicy.BOTH);

	dataTable.setColumnSorter(new ExtendedColumnSorter());

	// Sets some events
	DOM.sinkEvents(getDataWrapper(), Event.ONCLICK | Event.ONDBLCLICK | Event.ONMOUSEDOWN);
}
 
Example 23
Project: document-management-system   File: ExtendedFlexTable.java   Source Code and License 6 votes vote down vote up
/**
 * Method originally copied from HTMLTable superclass where it was defined private
 * Now implemented differently to only return target cell if it'spart of 'this' table
 */
private Element getMouseEventTargetCell(Event event) {
	Element td = DOM.eventGetTarget(event);
	//locate enclosing td element
	while (!DOM.getElementProperty(td, "tagName").equalsIgnoreCase("td")) {
		// If we run out of elements, or run into the table itself, then give up.
		if ((td == null) || td == getElement())
			return null;
		td = DOM.getParent(td);
	}
	//test if the td is actually from this table
	Element tr = DOM.getParent(td);
	Element body = DOM.getParent(tr);
	if (body == this.getBodyElement()) {
		return td;
	}
	//Didn't find appropriate cell
	return null;
}
 
Example 24
Project: document-management-system   File: ExtendedFlexTable.java   Source Code and License 6 votes vote down vote up
/**
 * ExtendedFlexTable
 */
public ExtendedFlexTable() {
	super();

	// Adds double click event control to table ( on default only has CLICK )
	sinkEvents(Event.ONDBLCLICK | Event.MOUSEEVENTS);
	addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			// Mark selected row or orders rows if header row (0) is clicked 
			// And row must be other than the selected one
			markSelectedRow(getCellForEvent(event).getRowIndex());
			MessagingToolBarBox.get().messageDashboard.messageStack.messageSent.refreshMessagesSent();
		}
	});
}
 
Example 25
Project: document-management-system   File: ExtendedFlexTable.java   Source Code and License 6 votes vote down vote up
/**
 * ExtendedFlexTable
 */
public ExtendedFlexTable() {
	super();

	// Adds double click event control to table ( on default only has CLICK )
	sinkEvents(Event.ONDBLCLICK | Event.MOUSEEVENTS);
	addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			// Mark selected row or orders rows if header row (0) is clicked 
			// And row must be other than the selected one
			markSelectedRow(getCellForEvent(event).getRowIndex());
			MessagingToolBarBox.get().messageDashboard.messageStack.proposedQueryReceived.refreshProposedQueries();
		}
	});
}
 
Example 26
Project: cuba   File: Tools.java   Source Code and License 6 votes vote down vote up
@Override
protected void onPreviewNativeEvent(Event.NativePreviewEvent event) {
    super.onPreviewNativeEvent(event);

    NativeEvent nativeEvent = event.getNativeEvent();
    Element target = Element.as(nativeEvent.getEventTarget());

    if (Event.ONCLICK == event.getTypeInt()) {
        final Widget hoveredButton = WidgetUtil.findWidget(target, null);
        if (getElement().isOrHasChild(target)) {
            Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
                @Override
                public void execute() {
                    hide();

                    if (BrowserInfo.get().isIE9()) {
                        if (hoveredButton instanceof CubaButtonWidget) {
                            hoveredButton.removeStyleName("ie9-hover");
                        }
                    }
                }
            });
        }
    }
}
 
Example 27
Project: document-management-system   File: ExtendedFlexTable.java   Source Code and License 6 votes vote down vote up
/**
 * ExtendedFlexTable
 */
public ExtendedFlexTable() {
	super();

	// Adds double click event control to table ( on default only has CLICK )
	sinkEvents(Event.ONDBLCLICK | Event.MOUSEEVENTS);
	addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			// Mark selected row or orders rows if header row (0) is clicked 
			// And row must be other than the selected one
			markSelectedRow(getCellForEvent(event).getRowIndex());
			MessagingToolBarBox.get().messageDashboard.messageStack.proposedSubscriptionReceived.refreshProposedSubscriptions();
		}
	});
}
 
Example 28
Project: document-management-system   File: ExtendedScrollTable.java   Source Code and License 6 votes vote down vote up
/**
 * @param dataTable
 * @param headerTable
 * @param scrollTableImages
 */
public ExtendedScrollTable(FixedWidthGrid dataTable, FixedWidthFlexTable headerTable,
                           ScrollTableImages scrollTableImages) {
	super(dataTable, headerTable, scrollTableImages);
	formManager = new FormManager(); // Used to draw extended columns

	this.dataTable = dataTable;
	this.headerTable = headerTable;

	// Table data SortableFixedWidthGrid.HOVERING_POLICY_CELL
	dataTable.setSelectionPolicy(SelectionGrid.SelectionPolicy.ONE_ROW);
	setResizePolicy(ResizePolicy.FILL_WIDTH);
	setScrollPolicy(ScrollPolicy.BOTH);

	columnSorter = new ExtendedColumnSorter();
	dataTable.setColumnSorter(columnSorter);

	// Sets some events
	DOM.sinkEvents(getDataWrapper(), Event.ONCLICK | Event.ONDBLCLICK | Event.ONMOUSEDOWN | Event.ONMOUSEUP
			| Event.ONMOUSEMOVE | Event.ONMOUSEUP);
}
 
Example 29
Project: document-management-system   File: ExtendedScrollTable.java   Source Code and License 6 votes vote down vote up
/**
 * ExtendedScrollTable
 */
public ExtendedScrollTable(FixedWidthGrid dataTable, FixedWidthFlexTable headerTable, ScrollTableImages scrollTableImages) {
	super(dataTable, headerTable, scrollTableImages);
	this.dataTable = dataTable;
	this.headerTable = headerTable;

	formManager = new FormManager(); // Used to draw extended columns

	dataTable.setSelectionPolicy(SelectionGrid.SelectionPolicy.ONE_ROW);
	setResizePolicy(ResizePolicy.FILL_WIDTH);
	setScrollPolicy(ScrollPolicy.BOTH);

	columnSorter = new ExtendedColumnSorter();
	dataTable.setColumnSorter(columnSorter);

	// Sets some events
	DOM.sinkEvents(getDataWrapper(), Event.ONDBLCLICK | Event.ONMOUSEDOWN);
}
 
Example 30
Project: Wiab.pro   File: SignalEventImpl.java   Source Code and License 6 votes vote down vote up
private static <T extends SignalEventImpl> T createInner(
    SignalEventFactory<T> factory, Event event) {

  SignalKeyLogic.Result keySignalResult;
  if (isKeyEvent(event)) {
    keySignalResult = computeKeySignalTypeResult;
    logic.computeKeySignalType(keySignalResult,
        event.getType(), getNativeKeyCode(event), getWhich(event), getKeyIdentifier(event),
        event.getMetaKey(), event.getCtrlKey(), event.getAltKey(), event.getShiftKey());

  } else {
    keySignalResult = null;
  }

  return createInner(createFor(factory, event), event.<JsoNativeEvent>cast(), keySignalResult);
}
 
Example 31
Project: cuba   File: CubaResizableTextAreaWrapperWidget.java   Source Code and License 6 votes vote down vote up
protected void captureEvents(Event event) {
    event.preventDefault();
    if (isEnabled() && event.getButton() == Event.BUTTON_LEFT) {
        if (!dragDrop) {
            dragDrop = true;
            DOM.setCapture(resizeElement);

            ComputedStyle cs = new ComputedStyle(getElement());
            setWidth(cs.getProperty("width"));
            setHeight(cs.getProperty("height"));

            getTextArea().getStyle().setProperty("width", "100%");
            getTextArea().getStyle().setProperty("height", "100%");
        }
    }
}
 
Example 32
Project: document-management-system   File: UserNews.java   Source Code and License 6 votes vote down vote up
/**
 * UserNews
 */
public UserNews() {
	data = new HashMap<Integer, GWTQueryParams>();
	table = new ExtendedFlexTable();
	menuPopup = new MenuPopup();
	menuPopup.setStyleName("okm-MenuPopup");
	status = new Status();
	status.setStyleName("okm-StatusPopup");

	table.setBorderWidth(0);
	table.setCellSpacing(0);
	table.setCellSpacing(0);

	table.sinkEvents(Event.ONDBLCLICK | Event.ONMOUSEDOWN);

	initWidget(table);

}
 
Example 33
Project: Wiab.pro   File: KeyBindingRegistryIntegrationGwtTest.java   Source Code and License 6 votes vote down vote up
/**
 * Ensure that an action bound to ORDER_G is executed when the appropriate JS keypress
 * event is fired at the editor.
 */
public void testKeyBinding() {
  KeyBindingRegistry bindings = new KeyBindingRegistry();
  callTracker = 0;
  EditorAction testAction =
      new EditorAction() {

        @Override
        public void execute(EditorContext context) {
          callTracker++;
        }
      };
  bindings.registerAction(KeyCombo.CTRL_G, testAction);
  EditorImpl editor = createEditor(bindings);

  // 103 = g, this event = CTRL_G which is bound to ORDER_G by the EventWrapper
  Event rawEvent = Document.get().createKeyPressEvent(
      true, false, false, false, G_CODE, G_CODE).cast();
  editor.onJavaScriptEvent(JsEvents.KEY_PRESS, rawEvent);
  assertEquals("Callback action not called on registered keypress", callTracker, 1);
}
 
Example 34
Project: dangchat-sdk   File: JsFacade.java   Source Code and License 6 votes vote down vote up
@UsedByApp
public void handleLinkClick(Event event) {
    Element target = Element.as(event.getEventTarget());
    String href = target.getAttribute("href");
    if (href.startsWith("send:")) {
        String msg = href.substring("send:".length());
        msg = URL.decode(msg);
        if (lastVisiblePeer != null) {
            messenger.sendMessage(lastVisiblePeer, msg);
            event.preventDefault();
        }
    } else {
        if (JsElectronApp.isElectron()) {
            JsElectronApp.openUrlExternal(href);
            event.preventDefault();
        }
    }
}
 
Example 35
Project: cuba   File: CubaScrollBoxLayoutWidget.java   Source Code and License 6 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
    super.onBrowserEvent(event);

    if (DOM.eventGetType(event) == Event.ONSCROLL) {
        Element element = getElement();

        int scrollTop = element.getScrollTop();
        int scrollLeft = element.getScrollLeft();

        if (this.scrollTop != scrollTop || this.scrollLeft != scrollLeft) {
            if (onScrollHandler != null) {
                onScrollHandler.accept(scrollTop, scrollLeft);
            }

            this.scrollTop = scrollTop;
            this.scrollLeft = scrollLeft;
        }
    }
}
 
Example 36
Project: cuba   File: CubaCheckBoxConnector.java   Source Code and License 6 votes vote down vote up
@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    getWidget().captionManagedByLayout = getState().captionManagedByLayout;

    super.onStateChanged(stateChangeEvent);

    if (!getWidget().captionManagedByLayout
            && isContextHelpIconEnabled()) {
        if (getWidget().contextHelpIcon == null) {
            getWidget().contextHelpIcon = DOM.createSpan();
            getWidget().contextHelpIcon.setInnerHTML("?");
            getWidget().contextHelpIcon.setClassName(CONTEXT_HELP_CLASSNAME);
            Roles.getTextboxRole().setAriaHiddenState(getWidget().contextHelpIcon, true);

            getWidget().getElement().appendChild(getWidget().contextHelpIcon);
            DOM.sinkEvents(getWidget().contextHelpIcon, VTooltip.TOOLTIP_EVENTS | Event.ONCLICK);
        } else {
            getWidget().contextHelpIcon.getStyle().clearDisplay();
        }
    } else if (getWidget().contextHelpIcon != null) {
        getWidget().contextHelpIcon.getStyle()
                .setDisplay(Style.Display.NONE);

        getWidget().setAriaInvalid(false);
    }
}
 
Example 37
Project: cuba   File: CubaTreeWidget.java   Source Code and License 6 votes vote down vote up
@Override
protected void prepareToFireClick(int eventType) {
    if (eventType == Event.ONDBLCLICK && doubleClickHandling) {
        if (selectable) {
            CubaTreeWidget.this.deselectAll();

            TreeNode targetNode = getNodeByKey(key);
            targetNode.setFocused(true);

            targetNode.setSelected(true);
            selectedIds.add(targetNode.key);

            client.updateVariable(paintableId, "selected",
                    selectedIds.toArray(new String[selectedIds.size()]),
                    false);
            selectionHasChanged = false;
        }
    }
}
 
Example 38
Project: empiria.player   File: ItemBodyView.java   Source Code and License 5 votes vote down vote up
public ItemBodyView(WidgetWorkflowListener wwl) {
    widgetWorkflowListener = wwl;

    setStyleName("qp-text-module");
    this.sinkEvents(Event.ONCHANGE);
    this.sinkEvents(Event.ONMOUSEDOWN);
    this.sinkEvents(Event.ONMOUSEUP);
    this.sinkEvents(Event.ONMOUSEMOVE);
    this.sinkEvents(Event.ONMOUSEOUT);
}
 
Example 39
Project: empiria.player   File: AssessmentBodyView.java   Source Code and License 5 votes vote down vote up
@Inject
public AssessmentBodyView(@Assisted WidgetWorkflowListener wwl, ModeStyleNameConstants modeStyleNameConstants, StyleNameConstants styleNameConstants, PlayerWorkModeService playerWorkModeService) {
    widgetWorkflowListener = wwl;
    this.modeStyleNameConstants = modeStyleNameConstants;
    this.playerWorkModeService = playerWorkModeService;
    this.styleNameConstants = styleNameConstants;
    setStyleName(styleNameConstants.QP_ASSESSMENT_VIEW());
    this.sinkEvents(Event.ONCHANGE);
    this.sinkEvents(Event.ONMOUSEDOWN);
    this.sinkEvents(Event.ONMOUSEUP);
    this.sinkEvents(Event.ONMOUSEMOVE);
    this.sinkEvents(Event.ONMOUSEOUT);
}
 
Example 40
Project: empiria.player   File: AccessibleRadioButton.java   Source Code and License 5 votes vote down vote up
/**
 * Creates a new radio associated with a particular group name. All radio buttons associated with the same group name belong to a mutually-exclusive set.
 * <p/>
 * Radio buttons are grouped by their name attribute, so changing their name using the setName() method will also change their associated group.
 *
 * @param name the group name with which to associate the radio button
 */
public AccessibleRadioButton(String name) {
    super(DOM.createInputRadio(name));
    setStyleName("gwt-RadioButton");

    sinkEvents(Event.ONCLICK);
    sinkEvents(Event.ONMOUSEUP);
    sinkEvents(Event.ONBLUR);
    sinkEvents(Event.ONKEYDOWN);
}
 
Example 41
Project: empiria.player   File: AccessibleRadioButton.java   Source Code and License 5 votes vote down vote up
/**
 * Overridden to send ValueChangeEvents only when appropriate.
 */
@Override
public void onBrowserEvent(Event event) {
    switch (DOM.eventGetType(event)) {
        case Event.ONMOUSEUP:
        case Event.ONBLUR:
        case Event.ONKEYDOWN:
            // Note the old value for onValueChange purposes (in ONCLICK case)
            oldValue = getValue();
            break;

        case Event.ONCLICK:
            EventTarget target = event.getEventTarget();
            if (Element.is(target) && labelElem.isOrHasChild(Element.as(target))) {

                // They clicked the label. Note our pre-click value, and
                // short circuit event routing so that other click handlers
                // don't hear about it
                oldValue = getValue();
                return;
            }

            // It's not the label. Let our handlers hear about the
            // click...
            super.onBrowserEvent(event);
            // ...and now maybe tell them about the change
            ValueChangeEvent.fireIfNotEqual(AccessibleRadioButton.this, oldValue, getValue());
            return;
    }

    super.onBrowserEvent(event);
}
 
Example 42
Project: empiria.player   File: AccessibleRadioButton.java   Source Code and License 5 votes vote down vote up
@Override
public void sinkEvents(int eventBitsToAdd) {
    // Like CheckBox, we want to hear about inputElem. We
    // also want to know what's going on with the label, to
    // make sure onBrowserEvent is able to record value changes
    // initiated by label events
    if (isOrWasAttached()) {
        Event.sinkEvents(inputElem, eventBitsToAdd | Event.getEventsSunk(inputElem));
        Event.sinkEvents(labelElem, eventBitsToAdd | Event.getEventsSunk(labelElem));
    } else {
        super.sinkEvents(eventBitsToAdd);
    }
}
 
Example 43
Project: empiria.player   File: AccessibleCheckBox.java   Source Code and License 5 votes vote down vote up
@Override
public void sinkEvents(int eventBitsToAdd) {
    if (isOrWasAttached()) {
        Event.sinkEvents(inputElem, eventBitsToAdd | Event.getEventsSunk(inputElem));
    } else {
        super.sinkEvents(eventBitsToAdd);
    }
}
 
Example 44
Project: unitimes   File: CurriculumProjectionRulesPage.java   Source Code and License 5 votes vote down vote up
private boolean focus(Event event, int oldRow, int oldCol, int row, int col) {
	if (!getRowFormatter().isVisible(row) || col >= getCellCount(row)) return false;
	final Widget w = getWidget(row, col);
	if (w == null || !w.isVisible()) return false;
	if (w instanceof Updatable) {
		((Updatable)w).focus();
		event.stopPropagation();
		return true;
	}
	return false;
}
 
Example 45
Project: unitimes   File: CourseCurriculaTable.java   Source Code and License 5 votes vote down vote up
public MyFlexTable() {
	super();
	sinkEvents(Event.ONMOUSEOVER);
	sinkEvents(Event.ONMOUSEOUT);
	sinkEvents(Event.ONCLICK);
	setCellPadding(2);
	setCellSpacing(0);
}
 
Example 46
Project: unitimes   File: CourseCurriculaTable.java   Source Code and License 5 votes vote down vote up
public void onBrowserEvent(Event event) {
	Element td = getEventTargetCell(event);
	if (td==null) return;
    Element tr = DOM.getParent(td);
    Element body = DOM.getParent(tr);
    final int row = DOM.getChildIndex(body, tr);

    final ChainedCommand command = iRowClicks.get(row);
    
    switch (DOM.eventGetType(event)) {
	case Event.ONMOUSEOVER:
		getRowFormatter().setStyleName(row, "unitime-TableRowHover");
		if (command == null) getRowFormatter().getElement(row).getStyle().setCursor(Cursor.AUTO);
		break;
	case Event.ONMOUSEOUT:
		getRowFormatter().setStyleName(row, null);	
		break;
	case Event.ONCLICK:
		if (command == null) break;
		if (command.getLoadingMessage() != null)
			LoadingWidget.getInstance().show(command.getLoadingMessage());
		getRowFormatter().setStyleName(row, "unitime-TableRowSelected");
		iSelectedRow = row;
		command.execute(new ConditionalCommand() {
			@Override
			public void executeOnSuccess() {
				//getRowFormatter().setStyleName(row, null);	
				if (command.getLoadingMessage() != null)
					LoadingWidget.getInstance().hide();
			}
			@Override
			public void executeOnFailure() {
				getRowFormatter().setStyleName(row, "unitime-TableRowHover");	
				if (command.getLoadingMessage() != null)
					LoadingWidget.getInstance().hide();
			}
		});
		break;
	}
}
 
Example 47
Project: unitimes   File: ClickableHint.java   Source Code and License 5 votes vote down vote up
public ClickableHint(String text) {
	super(text);
	getElement().setTabIndex(0);
	setStyleName("unitime-Hint");
	sinkEvents(Event.KEYEVENTS);
	Roles.getLinkRole().set(getElement());
}
 
Example 48
Project: unitimes   File: ClickableHint.java   Source Code and License 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 49
Project: unitimes   File: AriaSuggestBox.java   Source Code and License 5 votes vote down vote up
SuggestionMenu() {
	super(true);
	setStyleName("");
	setFocusOnHoverEnabled(false);
	sinkEvents(Event.ONBLUR);
	sinkEvents(Event.ONFOCUS);
}
 
Example 50
Project: unitimes   File: AriaSuggestBox.java   Source Code and License 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 51
Project: unitimes   File: AriaToggleButton.java   Source Code and License 5 votes vote down vote up
public AriaToggleButton(ImageResource checked, ImageResource unchecked) {
	iCheckedFace = checked; iUncheckedFace = unchecked;
	setResource(iUncheckedFace);
	Roles.getCheckboxRole().set(getElement());
	Roles.getCheckboxRole().setAriaCheckedState(getElement(), CheckedValue.FALSE);
	setTabIndex(0);
	sinkEvents(Event.ONKEYUP | Event.ONCLICK);
}
 
Example 52
Project: unitimes   File: AriaToggleButton.java   Source Code and License 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) {
	if (event.getTypeInt() == Event.ONKEYUP && event.getKeyCode() == KeyCodes.KEY_SPACE) {
		onClick();
	}
	if (event.getTypeInt() == Event.ONCLICK) {
		setValue(!getValue());
	}
	super.onBrowserEvent(event);
}
 
Example 53
Project: unitimes   File: RoomsTable.java   Source Code and License 5 votes vote down vote up
LinkCell(RoomPictureInterface picture) {
super(new Image(RESOURCES.download()), GWT.getHostPageBaseURL() + "picture?id=" + picture.getUniqueId());
setStyleName("link");
setTitle(picture.getName() + (picture.getPictureType() == null ? "" : " (" + picture.getPictureType().getLabel() + ")"));
setText(picture.getName() + (picture.getPictureType() == null ? "" : " (" + picture.getPictureType().getAbbreviation() + ")"));
      setTarget("_blank");
      sinkEvents(Event.ONCLICK);
  }
 
Example 54
Project: unitimes   File: RoomsTable.java   Source Code and License 5 votes vote down vote up
@Override
public void onBrowserEvent(Event event) { 
    if(event.getTypeInt() == Event.ONCLICK) {
    	event.stopPropagation(); 
    } 
    super.onBrowserEvent(event); 
}
 
Example 55
Project: unitimes   File: TravelTimes.java   Source Code and License 5 votes vote down vote up
private P(String caption, String... styles) {
	iCaption = caption;
	if (caption != null)
		getElement().setInnerHTML(caption);
	for (String style: styles)
		if (style != null && !style.isEmpty())
			addStyleName(style);
	sinkEvents(Event.ONMOUSEDOWN);
}
 
Example 56
Project: unitimes   File: TravelTimes.java   Source Code and License 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 57
Project: unitimes   File: TimetableGrid.java   Source Code and License 5 votes vote down vote up
private Meeting(TimetableGridCell cell, boolean showRoom, boolean showInstructor, boolean showTime, boolean showPreference, boolean showDate) {
	super();
	iCell = cell;
	
       setStyleName("meeting");
       if (cell.hasBackground())
       	getElement().getStyle().setBackgroundColor(cell.getBackground());
       
       P header = new P("header", "label");
       header.setHeight(sLineHeight * cell.getNrNames());
       header.setHTML(cell.getName("<br>"));
       header.getElement().getStyle().setWhiteSpace(WhiteSpace.NOWRAP);
       if (cell.isItalics())
       	header.getElement().getStyle().setFontStyle(FontStyle.ITALIC);
       add(header);

       P footer = new P("footer");
       String notes = "";
       if (showTime && cell.hasTime()) notes += (notes.isEmpty() ? "" : "<br>") + cell.getTime();
       if (showDate && cell.hasDate()) notes += (notes.isEmpty() ? "" : "<br>") + cell.getDate();
       if (showRoom && cell.getNrRooms() > 0) notes += (notes.isEmpty() ? "" : "<br>") + cell.getRoom("<br>");
       if (showInstructor && cell.getNrInstructors() > 0) notes += (notes.isEmpty() ? "" : "<br>") + cell.getInstructor("<br>");
       if (showPreference && cell.hasPreference()) notes += (notes.isEmpty() ? "" : "<br>") + "<span style='color:rgb(200,200,200)'>" + cell.getPreference() + "</span>";
       footer.setHTML(notes);
       footer.getElement().getStyle().setWhiteSpace(WhiteSpace.NOWRAP);
       add(footer);
       
       sinkEvents(Event.ONCLICK);
	sinkEvents(Event.ONMOUSEOVER);
	sinkEvents(Event.ONMOUSEOUT);
	
	getElement().getStyle().setPosition(Position.ABSOLUTE);
}
 
Example 58
Project: unitimes   File: UniTimeTable.java   Source Code and License 5 votes vote down vote up
public TableEvent(Event sourceEvent, int row, int col, Element tr, Element td, T data) {
	iRow = row;
	iCol = col;
	iTR = tr;
	iTD = td;
	iData = data;
	iSourceEvent = sourceEvent;
}
 
Example 59
Project: unitimes   File: ImageLink.java   Source Code and License 5 votes vote down vote up
private void initElements() { 
    iElement = Document.get().createSpanElement(); 
    iAnchor = Document.get().createAnchorElement(); 
    iElement.appendChild(iAnchor); 
    setElement(iElement); 
    sinkEvents(Event.MOUSEEVENTS); 
    setTarget("_blank"); 
}
 
Example 60
Project: unitimes   File: TimeSelector.java   Source Code and License 5 votes vote down vote up
TimeMenu() {
	super(true);
	setStyleName("");
	setFocusOnHoverEnabled(false);
	setFocusOnHoverEnabled(false);
	sinkEvents(Event.ONBLUR);
	sinkEvents(Event.ONFOCUS);
}