Java Code Examples for com.google.gwt.event.dom.client.MouseUpEvent#getNativeButton()

The following examples show how to use com.google.gwt.event.dom.client.MouseUpEvent#getNativeButton() . 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: GanttWidget.java    From gantt with Apache License 2.0 6 votes vote down vote up
@Override
public void onMouseUp(MouseUpEvent event) {
    GWT.log("onMouseUp(MouseUpEvent)");
    if (event.getNativeButton() == NativeEvent.BUTTON_LEFT) {
        GanttWidget.this.onTouchOrMouseUp(event.getNativeEvent());

    } else {
        if (secondaryClickOnNextMouseUp) {
            Element bar = getBar(event.getNativeEvent());
            if (bar != null && isEnabled()) {
                getRpc().stepClicked(getStepUid(bar), event.getNativeEvent(), bar);
            }
        }
        secondaryClickOnNextMouseUp = true;
    }
}
 
Example 2
Source File: DiagramController.java    From EasyML with Apache License 2.0 5 votes vote down vote up
/**
 * Trigger action when mouse up event fired
 * 
 * @param event
 */
protected void onMouseUp(MouseUpEvent event) {
	// Test if Right Click
	if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
		logger.info( "Handle NativeEvent.BUTTON_RIGHT begin >");
		event.stopPropagation();
		event.preventDefault();
		logger.info("Handle NativeEvent.BUTTON_RIGHT end <");
		return;
	}

	if ( !lockDrawConnection && inDragBuildConnection ) {
		logger.info( "draw connection lock: " +  lockDrawConnection );
		NodeShape shape = (NodeShape) getShapeUnderMouse();
		if (shape != null && shape instanceof InNodeShape) {
			Connection c = connfactory.buildConnection(this, startShape, shape);
			if (c == null) {
				Window.alert("Connection can't be build");
			} else {
				c.draw();
				connDrawSet.add(c);
				((NodeShape) startShape).onConnectionEnd(c);
				shape.onConnectionEnd(c);
			}
		}else {
			((NodeShape) startShape).onConnectionCancel();
		}
		deleteConnection(buildConnection);
		inDragBuildConnection = false;
		buildConnection = null;
	}
}
 
Example 3
Source File: MonitorController.java    From EasyML with Apache License 2.0 5 votes vote down vote up
@Override
public void onMouseUp(MouseUpEvent event) {
	super.onMouseUp(event);
	if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
		NodeShape shape = (NodeShape) getShapeUnderMouse();
		if (shape instanceof OutNodeShape) {
			OutNodeShape outShape = (OutNodeShape)shape;
			int x = outShape.getOffsetLeft() + 2*outShape.getRadius();
			int y = outShape.getOffsetTop() + 2*outShape.getRadius();
			outShape.getContextMenu().setPopupPosition(x,y);
			outShape.getContextMenu().show();
		}
	}
}
 
Example 4
Source File: DiagramController.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void onMouseUp(MouseUpEvent event) {

		// Test if Right Click
		if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
			event.stopPropagation();
			event.preventDefault();
			showContextualMenu();
			return;
		}

		if (inDragMovablePoint) {
			movablePoint.setFixed(true);
			topCanvas.setBackground();
			inDragMovablePoint = false;
			highlightConnection.setAllowSynchronized(true);
			return;
		}

		if (inDragBuildArrow) {
			FunctionShape functionUnderMouse = getShapeUnderMouse();
			if (functionUnderMouse != null) {
				Widget widgetSelected = functionUnderMouse.asWidget();
				if (startFunctionWidget != widgetSelected) {
					Connection c = drawStraightArrowConnection(startFunctionWidget, widgetSelected, (String) null);
					fireEvent(new TieLinkEvent(startFunctionWidget, widgetSelected, c));
				}
			}
			topCanvas.setBackground();
			deleteConnection(buildConnection);
			inDragBuildArrow = false;
			buildConnection = null;
			if (highlightFunctionShape != null) {
				highlightFunctionShape.draw();
				highlightFunctionShape = null;
			}
			clearAnimationsOnCanvas();
		}

		if (inEditionDragMovablePoint) {
			inEditionDragMovablePoint = false;
			clearAnimationsOnCanvas();
		}
	}
 
Example 5
Source File: DateCell.java    From calendar-component with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public void onMouseUp(MouseUpEvent event) {

    if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
        return;
    }

    Event.releaseCapture(getElement());
    setFocus(false);

    // Drag initialized?
    if (eventRangeStart >= 0) {
        Element main = getElement();
        if (eventRangeStart > eventRangeStop) {
            if (eventRangeStop <= -1) {
                eventRangeStop = 0;
            }
            int temp = eventRangeStart;
            eventRangeStart = eventRangeStop;
            eventRangeStop = temp;
        }

        // This happens for single clicks without dragging on the calendar
        if(eventRangeStart == eventRangeStop) {
            handleEventRange(event);
        }

        NodeList<Node> nodes = main.getChildNodes();

        int slotStart = -1;
        int slotEnd = -1;

        // iterate over all child nodes, until we find first the start,
        // and then the end
        for (int i = 0; i < nodes.getLength(); i++) {
            Element element = (Element) nodes.getItem(i);
            boolean isRangeElement = element.getClassName().contains("v-daterange");

            if (isRangeElement && slotStart == -1) {
                slotStart = i;
                slotEnd = i; // to catch one-slot selections

            } else if (isRangeElement) {
                slotEnd = i;

            } else if (slotStart != -1 && slotEnd != -1) {
                break; // FIXME ! is 'else if' right
            }
        }

        clearSelectionRange();

        int startMinutes = firstHour * 60 + slotStart * 30;
        int endMinutes = (firstHour * 60) + (slotEnd + 1) * 30;
        Date currentDate = getDate();

        if (weekgrid.getCalendar().getRangeSelectListener() != null) {

            SelectionRange weekSelection = new SelectionRange();
            weekSelection.sMin = startMinutes;
            weekSelection.eMin = endMinutes;
            weekSelection.setStartDay(DateConstants.toRPCDate(
                    currentDate.getYear(),
                    currentDate.getMonth(),
                    currentDate.getDate()));

            weekgrid.getCalendar().getRangeSelectListener().rangeSelected(weekSelection);
        }
        eventRangeStart = -1;

    } else {

        // Click event
        eventRangeStart = -1;
        cancelRangeSelect();
    }
}