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   View source code 7 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: empiria.player   File: AbstractMediaScroll.java   View source code 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 3
Project: empiria.player   File: AbstractMediaButton.java   View source code 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 4
Project: empiria.player   File: AccessibleCheckBox.java   View source code 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 5
Project: unitimes   File: SimpleEditPage.java   View source code 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 6
Project: unitimes   File: CurriculumProjectionRulesPage.java   View source code 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 7
Project: unitimes   File: ImageButton.java   View source code 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 8
Project: unitimes   File: TimetableGrid.java   View source code 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 9
Project: unitimes   File: UniTimeTable.java   View source code 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 10
Project: unitimes   File: HorizontalPanelWithHint.java   View source code 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 11
Project: unitimes   File: TimeGrid.java   View source code 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 12
Project: unitimes   File: TimeGrid.java   View source code 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 13
Project: unitimes   File: SessionDatesSelector.java   View source code 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 14
Project: unitimes   File: InfoPanelImpl.java   View source code 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 15
Project: appinventor-extensions   File: Icon.java   View source code 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 16
Project: appinventor-extensions   File: MockComponent.java   View source code 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 17
Project: appinventor-extensions   File: MockComponent.java   View source code 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 18
Project: cuba   File: CubaSideMenuWidget.java   View source code 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 19
Project: vaadin-combobox-multiselect   File: VComboBoxMultiselect.java   View source code 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 20
Project: LAS   File: WindowBox.java   View source code 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 21
Project: document-management-system   File: ExtendedScrollTable.java   View source code 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 22
Project: document-management-system   File: ExtendedFlexTable.java   View source code 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 23
Project: document-management-system   File: ExtendedFlexTable.java   View source code 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 24
Project: document-management-system   File: ExtendedFlexTable.java   View source code 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 25
Project: cuba   File: Tools.java   View source code 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 26
Project: document-management-system   File: ExtendedFlexTable.java   View source code 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 27
Project: document-management-system   File: ExtendedScrollTable.java   View source code 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 28
Project: document-management-system   File: ExtendedScrollTable.java   View source code 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 29
Project: Wiab.pro   File: SignalEventImpl.java   View source code 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 30
Project: cuba   File: CubaResizableTextAreaWrapperWidget.java   View source code 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 31
Project: document-management-system   File: ExtendedFlexTable.java   View source code 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 32
Project: document-management-system   File: UserNews.java   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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);
}