com.google.gwt.event.dom.client.ContextMenuEvent Java Examples

The following examples show how to use com.google.gwt.event.dom.client.ContextMenuEvent. 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: DateCell.java    From calendar-component with Apache License 2.0 5 votes vote down vote up
@Override
protected void onAttach() {
    super.onAttach();

    handlers.add(addHandler(this, MouseDownEvent.getType()));
    handlers.add(addHandler(this, MouseUpEvent.getType()));
    handlers.add(addHandler(this, MouseMoveEvent.getType()));
    handlers.add(addDomHandler(this, ContextMenuEvent.getType()));
    handlers.add(addKeyDownHandler(this));
}
 
Example #2
Source File: DateCell.java    From calendar-component with Apache License 2.0 5 votes vote down vote up
@Override
public void onContextMenu(ContextMenuEvent event) {
    if (weekgrid.getCalendar().getMouseEventListener() != null) {
        event.preventDefault();
        event.stopPropagation();
        weekgrid.getCalendar().getMouseEventListener().contextMenu(event,
                DateCell.this);
    }
}
 
Example #3
Source File: MonthItemLabel.java    From calendar-component with Apache License 2.0 5 votes vote down vote up
/**
 * Default constructor
 */
public MonthItemLabel() {
    setStylePrimaryName(STYLENAME);

    addDomHandler(contextMenuEvent -> {
        calendar.getMouseEventListener().contextMenu(contextMenuEvent, MonthItemLabel.this);
        contextMenuEvent.stopPropagation();
        contextMenuEvent.preventDefault();
    }, ContextMenuEvent.getType());
}
 
Example #4
Source File: CirSim.java    From circuitjs1 with GNU General Public License v2.0 4 votes vote down vote up
public void onContextMenu(ContextMenuEvent e) {
	e.preventDefault();
	menuClientX = e.getNativeEvent().getClientX();
	menuClientY = e.getNativeEvent().getClientY();
	doPopupMenu();
}
 
Example #5
Source File: VCalendar.java    From calendar-component with Apache License 2.0 4 votes vote down vote up
/**
 * Updates the items in the Month view
 *
 * @param daysCount
 *            How many days there are
 * @param days
 *            The days
 * @param today
 *            Todays date
 */
@SuppressWarnings("deprecation")
public void updateMonthGrid(int daysCount, List<CalendarDay> days, Date today) {

    int columns = getLastDayNumber() - getFirstDayNumber() + 1;
    int rows = (int) Math.ceil(daysCount / (double) 7);

    monthGrid = new MonthGrid(this, rows, columns);
    monthGrid.setEnabled(!isDisabled());
    weekToolbar.removeAllRows();
    int pos = 0;
    boolean monthNameDrawn = true;
    boolean firstDayFound = false;
    boolean lastDayFound = false;

    for (CalendarDay day : days) {

        Date date = day.getDate();

        int dayOfWeek = day.getDayOfWeek();
        int week = day.getWeek();
        int dayOfMonth = date.getDate();

        // reset at start of each month
        if (dayOfMonth == 1) {
            monthNameDrawn = false;
            if (firstDayFound) {
                lastDayFound = true;
            }
            firstDayFound = true;
        }

        if (dayOfWeek < getFirstDayNumber() || dayOfWeek > getLastDayNumber()) {
            continue;
        }

        int y = (pos / columns);
        int x = pos - (y * columns);
        if (x == 0 && daysCount > 7) {
            // Add week to weekToolbar for navigation
            weekToolbar.addWeek(week, day.getYearOfWeek());
        }

        final SimpleDayCell cell = new SimpleDayCell(this, y, x);
        cell.setMonthGrid(monthGrid);
        cell.setDate(date);
        cell.addDomHandler(event -> {
            if (mouseEventListener != null) {
                event.preventDefault();
                event.stopPropagation();
                mouseEventListener.contextMenu(event, cell);
            }
        }, ContextMenuEvent.getType());

        if (!firstDayFound) {
            cell.addStyleDependentName("prev-month");
        } else if (lastDayFound) {
            cell.addStyleDependentName("next-month");
        }

        if (dayOfMonth >= 1 && !monthNameDrawn) {
            cell.setMonthNameVisible(true);
            monthNameDrawn = true;
        }

        if (today.getDate() == dayOfMonth && today.getYear() == date.getYear()
                && today.getMonth() == date.getMonth()) {
            cell.setToday(true);

        }
        monthGrid.setWidget(y, x, cell);
        pos++;
    }
}
 
Example #6
Source File: CubaMainTabSheetWidget.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
protected void onTabContextMenu(final int tabIndex, ContextMenuEvent event) {
    if (tabContextMenuHandler != null) {
        tabContextMenuHandler.onContextMenu(tabIndex, event);
    }
}
 
Example #7
Source File: GanttWidget.java    From gantt with Apache License 2.0 4 votes vote down vote up
@Override
public void onContextMenu(ContextMenuEvent event) {
    if (!defaultContextMenuEnabled) {
        event.preventDefault();
    }
}
 
Example #8
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 #9
Source File: VCalendar.java    From calendar-component with Apache License 2.0 2 votes vote down vote up
/**
 * Triggered when a user wants an context menu
 *
 * @param event
 *            The context menu event
 *
 * @param widget
 *            The widget that the context menu should be added to
 */
void contextMenu(ContextMenuEvent event, Widget widget);
 
Example #10
Source File: CubaMainTabSheetWidget.java    From cuba with Apache License 2.0 votes vote down vote up
void onContextMenu(final int tabIndex, ContextMenuEvent event);