Java Code Examples for com.google.gwt.user.client.Event#sinkEvents()

The following examples show how to use com.google.gwt.user.client.Event#sinkEvents() . 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: CubaGridEmptyState.java    From cuba with Apache License 2.0 6 votes vote down vote up
public CubaGridEmptyState() {
    container = Document.get().createDivElement();
    container.setClassName("c-datagrid-empty-state");

    messageBox = Document.get().createDivElement();
    messageBox.setClassName("c-datagrid-empty-state-message-box");

    messageLabel = Document.get().createDivElement();
    messageLabel.setClassName("c-datagrid-empty-state-message");

    linkMessageLabel = Document.get().createSpanElement();
    linkMessageLabel.setClassName("c-datagrid-empty-state-link-message v-button-link");

    container.appendChild(messageBox);

    Event.sinkEvents(container, Event.ONCLICK);
    Event.setEventListener(container, this);
}
 
Example 2
Source File: InputDatePicker.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void redrawMonthPicker() {
	this.monthPicker.getStyle().setWidth(this.calendarTable.getClientWidth(), Unit.PX);
	this.calendarTable.getStyle().setDisplay(Display.NONE);
	this.monthPicker.getStyle().clearDisplay();

	int currentYear = this.cursor.getYear() + InputDatePicker.YEAR_OFFSET;
	if (this.monthPickerInner.getChildCount() == 0) {
		for (int year = currentYear - 100; year < currentYear + 100; year++) {
			DivElement yearDiv = Document.get().createDivElement();
			yearDiv.setInnerText(String.valueOf(year));
			StyleUtils.addStyle(yearDiv, InputDatePicker.STYLE_YEAR_BUTTON);
			Event.sinkEvents(yearDiv, Event.ONCLICK);
			this.monthPickerInner.appendChild(yearDiv);
			yearDiv.setAttribute(InputDatePicker.ATTRIBUTE_DATA_YEAR, String.valueOf(year));
		}
	}
	this.openMonthOfYear(this.cursor.getYear() + InputDatePicker.YEAR_OFFSET);
}
 
Example 3
Source File: PerspectiveDragConfigModalView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void addItem(String name, Command onSelect) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    selectorItems.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            onSelect.execute();
        }
    });
}
 
Example 4
Source File: PerspectivesExplorerView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void addPerspective(String name, Command onClicked) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.getStyle().setCursor(Style.Cursor.POINTER);
    anchor.getStyle().setColor("black");
    anchor.getStyle().setProperty("fontSize", "larger");
    anchor.setInnerText(name);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            onClicked.execute();
        }
    });

    SpanElement icon = Document.get().createSpanElement();
    icon.getStyle().setMarginRight(10, Style.Unit.PX);
    icon.setClassName("pficon-virtual-machine");
    icon.getStyle().setProperty("fontSize", "larger");

    DivElement gi = createItemDiv(new Element[] {icon, anchor});
    perspectivesDiv.appendChild((Node) gi);
}
 
Example 5
Source File: TargetPerspectiveEditorView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
private void addItem(UnorderedList unorderedList, String name, boolean selected, Command onSelect) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    li.setClassName(selected ? "selected" : "");
    unorderedList.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            onSelect.execute();
        }
    });
}
 
Example 6
Source File: NavRootNodeEditorView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void addCommand(String name, Command command) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    commandMenu.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            command.execute();
        }
    });
}
 
Example 7
Source File: NavComponentConfigModalView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
private void addItem(UnorderedList unorderedList, String name, boolean selected, Command onSelect) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(name);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    li.setClassName(selected ? "selected" : "");
    unorderedList.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            onSelect.execute();
        }
    });
}
 
Example 8
Source File: NavTilesWidgetView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void addBreadcrumbItem(String navItemName, Command onClicked) {
    LIElement li = Document.get().createLIElement();
    breadcrumb.appendChild((Node) li);

    if (onClicked != null) {
        AnchorElement anchor = Document.get().createAnchorElement();
        anchor.setInnerText(navItemName);
        li.appendChild(anchor);
        li.getStyle().setCursor(Style.Cursor.POINTER);

        Event.sinkEvents(anchor, Event.ONCLICK);
        Event.setEventListener(anchor, event -> {
            if (Event.ONCLICK == event.getTypeInt()) {
                onClicked.execute();
            }
        });
    } else {
        ((Node) li).setTextContent(navItemName);
        li.setClassName("active");
    }
}
 
Example 9
Source File: SourceCodeEditorView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void declareVariable(String var, String description) {

    SpanElement span = Document.get().createSpanElement();
    span.setInnerText(var);

    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setTitle(description);
    anchor.appendChild(span);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);

    variablesMenu.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            presenter.onVariableSelected(var);
        }
    });
}
 
Example 10
Source File: DisplayerHtmlEditorView.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
@Override
public void addSourceCodeItem(String name) {
    AnchorElement anchor = Document.get().createAnchorElement();
    String displayName = DisplayerHtmlConstants.INSTANCE.getString("displayer_source_code_" + name);
    anchor.setInnerText(displayName);

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    tabList.appendChild((Node) li);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if(Event.ONCLICK == event.getTypeInt()) {
            presenter.onSourceCodeItemSelected(name);
            if (selectedItem != null) {
                selectedItem.setClassName("");
                selectedItem.getStyle().setCursor(Style.Cursor.POINTER);
            }
            selectedItem = li;
            selectedItem.setClassName("active");
            selectedItem.getStyle().setCursor(Style.Cursor.DEFAULT);
            previewItem.setClassName("");
        }
    });
}
 
Example 11
Source File: TopMenuBar.java    From dashbuilder with Apache License 2.0 6 votes vote down vote up
private void addEntry(String entry, boolean logout) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setInnerText(entry);

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if (Event.ONCLICK == event.getTypeInt()) {
            if (!logout) {
                onRoleClicked(entry);
            } else {
                onLogoutClicked();
            }
        }
    });

    LIElement li = Document.get().createLIElement();
    li.getStyle().setCursor(Style.Cursor.POINTER);
    li.appendChild(anchor);
    roleList.appendChild((Node) li);
}
 
Example 12
Source File: TableEmptyState.java    From cuba with Apache License 2.0 6 votes vote down vote up
public TableEmptyState() {
    container = Document.get().createDivElement();
    container.setClassName("c-table-empty-state");

    messageBox = Document.get().createDivElement();
    messageBox.setClassName("c-table-empty-state-message-box");

    messageLabel = Document.get().createDivElement();
    messageLabel.setClassName("c-table-empty-state-message");

    linkMessageLabel = Document.get().createSpanElement();
    linkMessageLabel.setClassName("c-table-empty-state-link-message v-button-link");

    container.appendChild(messageBox);

    Event.sinkEvents(container, Event.ONCLICK);
    Event.setEventListener(container, this);
}
 
Example 13
Source File: NavTreeWidgetView.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
protected void addItem(String iconClass, String id, String name, String description, Command onClicked) {
    Element nameEl = onClicked != null ? Document.get().createAnchorElement() : Document.get().createSpanElement();
    nameEl.setInnerText(name);
    nameEl.setClassName(onClicked != null ? "uf-navtree-widget-non-clicked" : "uf-navtree-widget-non-clickable");
    if (description != null && !description.equals(name)) {
        nameEl.setTitle(description);
    }

    SpanElement iconSpan = Document.get().createSpanElement();
    iconSpan.setClassName("uf-navtree-widget-icon " + iconClass);

    DivElement div = Document.get().createDivElement();
    div.appendChild(iconSpan);
    div.appendChild(nameEl);

    navWidget.appendChild((Node) div);
    itemMap.put(id, nameEl);

    if (onClicked != null) {
        Event.sinkEvents(nameEl, Event.ONCLICK);
        Event.setEventListener(nameEl, event -> {
            if (Event.ONCLICK == event.getTypeInt()) {
                onClicked.execute();
            }
        });
    }
}
 
Example 14
Source File: BaseCheckBox.java    From gwt-material with Apache License 2.0 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 15
Source File: CubaWindowWidget.java    From cuba with Apache License 2.0 5 votes vote down vote up
public CubaWindowWidget() {
    DOM.sinkEvents(header, DOM.getEventsSunk(header) | Event.ONCONTEXTMENU);
    addStyleName(NONMODAL_WINDOW_CLASSNAME);
    Event.sinkEvents(getModalityCurtain(), Event.ONCLICK);
    Event.setEventListener(getModalityCurtain(), event -> {
        if (closeOnClickOutside) {
            if (clickOnModalityCurtain != null) {
                clickOnModalityCurtain.run();
            }
        }
    });
}
 
Example 16
Source File: SvgArrowWidget.java    From gantt with Apache License 2.0 4 votes vote down vote up
protected void registerMouseDownAndTouchDownEventListener(
        final Element element) {
    Event.sinkEvents(element, Event.ONMOUSEDOWN | Event.ONTOUCHSTART);
}
 
Example 17
Source File: GanttWidget.java    From gantt with Apache License 2.0 4 votes vote down vote up
private void registerBarEventListener(final DivElement bar) {
    Event.sinkEvents(bar, Event.ONSCROLL | Event.MOUSEEVENTS | Event.TOUCHEVENTS);
}
 
Example 18
Source File: InputDatePicker.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
public InputDatePicker() {
	super(Document.get().createDivElement());

	StyleUtils.addStyle(this, InputDatePicker.STYLE_DATEPICKER);

	this.getElement().appendChild(this.datepickerHeader);
	StyleUtils.addStyle(this.datepickerHeader, InputDatePicker.STYLE_HEADER);

	/* month selecter */
	this.datepickerHeader.appendChild(this.monthPickerButton);
	StyleUtils.addStyle(this.monthPickerButton, InputDatePicker.STYLE_MONTH_PICKER_BUTTON);

	/* pagination */
	this.datepickerHeader.appendChild(this.monthPagerUl);
	StyleUtils.addStyle(this.monthPagerUl, InputDatePicker.STYLE_MONTH_PAGER);
	this.createLi(this.pagePreviusMonthLi, InputDatePicker.STYLE_MONTH_PREVIOUS, "&#9668;");
	this.createLi(this.pageTodayLi, InputDatePicker.STYLE_TODAY, "&#9673;");
	this.createLi(this.pageNextMonthLi, InputDatePicker.STYLE_MONTH_NEXT, "&#9658;");

	this.monthPagerUl.appendChild(this.pagePreviusMonthLi);
	this.monthPagerUl.appendChild(this.pageTodayLi);
	this.monthPagerUl.appendChild(this.pageNextMonthLi);

	/* Calendar Picker */
	this.getElement().appendChild(this.monthPicker);
	this.monthPicker.appendChild(this.monthPickerInner);
	StyleUtils.addStyle(this.monthPicker, InputDatePicker.STYLE_MONTH_PICKER);

	/* Calendar Picker */
	this.getElement().appendChild(this.calendarTable);
	StyleUtils.addStyle(this.calendarTable, InputDatePicker.STYLE_CALENDAR_PICKER);

	/* DayPicker Header */
	TableSectionElement head = Document.get().createTHeadElement();
	TableRowElement headRow = Document.get().createTRElement();
	this.calendarTable.appendChild(head);
	head.appendChild(headRow);
	for (int i = 0; i < 7; i++) {
		TableCellElement th = Document.get().createTHElement();
		headRow.appendChild(th);
		int dayToDisplay = (i + InputDatePicker.DATE_TIME_FORMAT_INFO.firstDayOfTheWeek()) % InputDatePicker.DAYS.length;
		th.setInnerText(InputDatePicker.DAYS[dayToDisplay]);
	}
	/* DayPicker Body */
	this.calendarTable.appendChild(this.calendatBody);

	this.today = InputDatePicker.ATTRIBUTE_DATE_FORMAT.parse(InputDatePicker.ATTRIBUTE_DATE_FORMAT.format(new Date()));
	this.setValue(this.today);

	Event.sinkEvents(this.getElement(), Event.ONKEYDOWN);
	Event.sinkEvents(this.monthPickerButton, Event.ONCLICK);
	Event.sinkEvents(this.pagePreviusMonthLi, Event.ONCLICK);
	Event.sinkEvents(this.pageTodayLi, Event.ONCLICK);
	Event.sinkEvents(this.pageNextMonthLi, Event.ONCLICK);

	this.redraw();
}
 
Example 19
Source File: GanttWidget.java    From gantt with Apache License 2.0 4 votes vote down vote up
/**
 * Reset listeners.
 */
public void resetListeners() {
    Event.sinkEvents(container, Event.ONSCROLL | Event.ONCONTEXTMENU);

    if (contextMenuHandlerRegistration == null) {
        contextMenuHandlerRegistration = addDomHandler(contextMenuHandler, ContextMenuEvent.getType());
    }

    if (scrollHandlerRegistration == null) {
        scrollHandlerRegistration = addHandler(scrollHandler, ScrollEvent.getType());
    }
    if (isMsTouchSupported()) {
        // IE10 pointer events (ms-prefixed events)
        if (pointerDownHandlerRegistration == null) {
            pointerDownHandlerRegistration = addDomHandler(msPointerDownHandler, PointerDownEvent.getType());
        }
        if (pointerUpHandlerRegistration == null) {
            pointerUpHandlerRegistration = addDomHandler(msPointerUpHandler, PointerUpEvent.getType());
        }
        if (pointerMoveHandlerRegistration == null) {
            pointerMoveHandlerRegistration = addDomHandler(msPointerMoveHandler, PointerMoveEvent.getType());
        }
        if (pointerCancelHandlerRegistration == null) {
            pointerCancelHandlerRegistration = addHandler(msPointerCancelHandler, PointerCancelEvent.getType());
        }
    } else if (touchSupported) {
        // touch events replaces mouse events
        if (touchStartHandlerRegistration == null) {
            touchStartHandlerRegistration = addDomHandler(touchStartHandler, TouchStartEvent.getType());
        }
        if (touchEndHandlerRegistration == null) {
            touchEndHandlerRegistration = addDomHandler(touchEndHandler, TouchEndEvent.getType());
        }
        if (touchMoveHandlerRegistration == null) {
            touchMoveHandlerRegistration = addDomHandler(touchMoveHandler, TouchMoveEvent.getType());
        }
        if (touchCancelHandlerRegistration == null) {
            touchCancelHandlerRegistration = addHandler(touchCancelHandler, TouchCancelEvent.getType());
        }

    } else {
        if (mouseDblClickHandlerRegistration == null) {
            mouseDblClickHandlerRegistration = addDomHandler(doubleClickHandler, DoubleClickEvent.getType());
        }
        if (mouseDownHandlerRegistration == null) {
            mouseDownHandlerRegistration = addDomHandler(mouseDownHandler, MouseDownEvent.getType());
        }
        if (mouseUpHandlerRegistration == null) {
            mouseUpHandlerRegistration = addDomHandler(mouseUpHandler, MouseUpEvent.getType());
        }
        if (isMovableSteps() || isResizableSteps()) {
            if (mouseMoveHandlerRegistration == null) {
                mouseMoveHandlerRegistration = addDomHandler(mouseMoveHandler, MouseMoveEvent.getType());
            }
        } else if (mouseMoveHandlerRegistration != null) {
            mouseMoveHandlerRegistration.removeHandler();
            mouseMoveHandlerRegistration = null;
        }
    }
}
 
Example 20
Source File: InputDatePicker.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void redrawCalendarPicker() {
	this.monthPicker.getStyle().setDisplay(Display.NONE);
	this.calendarTable.getStyle().clearDisplay();

	this.calendatBody.removeAllChildren();

	int firstDayOfWeek = InputDatePicker.DATE_TIME_FORMAT_INFO.firstDayOfTheWeek();
	int lastDayOfWeek = (firstDayOfWeek + InputDatePicker.DAYS_IN_WEEK) % InputDatePicker.DAYS_IN_WEEK;

	/* Display month */
	this.monthPickerButton.setInnerHTML(InputDatePicker.MONTH_YEAR_FORMAT.format(this.cursor)
		+ "<span class=\"caret\"></span>");

	Date lastMonth = new Date(this.cursor.getTime());
	CalendarUtil.addMonthsToDate(lastMonth, -1);
	this.pagePreviusMonthLi.setAttribute(InputDatePicker.ATTRIBUTE_DATA_CURSOR, InputDatePicker.ATTRIBUTE_DATE_FORMAT
		.format(lastMonth));
	this.pageTodayLi.setAttribute(InputDatePicker.ATTRIBUTE_DATA_CURSOR, InputDatePicker.ATTRIBUTE_DATE_FORMAT
		.format(this.today));
	Date nextMonth = new Date(this.cursor.getTime());
	CalendarUtil.addMonthsToDate(nextMonth, 1);
	this.pageNextMonthLi.setAttribute(InputDatePicker.ATTRIBUTE_DATA_CURSOR, InputDatePicker.ATTRIBUTE_DATE_FORMAT
		.format(nextMonth));

	/* Draw daypicker */
	Date dateToDrow = new Date(this.cursor.getTime());
	int selectedMonth = dateToDrow.getMonth();
	int firstMonthToDisplay = (selectedMonth + 11) % 12;
	int lastMonthToDisplay = (selectedMonth + 13) % 12;
	do {
		CalendarUtil.addDaysToDate(dateToDrow, -1);
	} while (firstMonthToDisplay != dateToDrow.getMonth() || dateToDrow.getDay() != firstDayOfWeek);

	// drow calendarTable
	TableRowElement headRow = null;
	while (dateToDrow.getMonth() != lastMonthToDisplay || dateToDrow.getDay() != lastDayOfWeek
		|| dateToDrow.getDate() == 1 && dateToDrow.getDay() == firstDayOfWeek) {
		if (headRow == null || dateToDrow.getDay() == firstDayOfWeek) {
			headRow = Document.get().createTRElement();
			this.calendatBody.appendChild(headRow);
		}
		TableCellElement td = Document.get().createTDElement();
		headRow.appendChild(td);
		DivElement div = Document.get().createDivElement();
		td.appendChild(div);
		div.setInnerText(String.valueOf(dateToDrow.getDate()));
		div.setAttribute(InputDatePicker.ATTRIBUTE_DATA_DATE, InputDatePicker.ATTRIBUTE_DATE_FORMAT.format(dateToDrow));
		if (dateToDrow.getMonth() != selectedMonth) {
			StyleUtils.addStyle(td, InputDatePicker.STYLE_MUTED);
		}
		if (dateToDrow.equals(this.cursor)) {
			StyleUtils.addStyle(td, InputDatePicker.STYLE_SELECTED);
		}
		if (this.today.equals(dateToDrow)) {
			StyleUtils.addStyle(td, InputDatePicker.STYLE_TODAY);
		}
		Event.sinkEvents(div, Event.ONCLICK);

		CalendarUtil.addDaysToDate(dateToDrow, 1);
	}
}