Java Code Examples for com.google.gwt.event.dom.client.MouseUpEvent

The following examples show how to use com.google.gwt.event.dom.client.MouseUpEvent. These examples are extracted from open source projects. 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
@Override
public void onMouseUp(MouseUpEvent event) {

	if (isDownPosition(event)) {

		Geometry point = new Geometry(Geometry.POINT, 0, -1);
		Coordinate coordinate = getLocation(event, RenderSpace.WORLD);
		point.setCoordinates(new Coordinate[] { coordinate });

		GeomajasServerExtension
				.getInstance()
				.getServerFeatureService()
				.search(mapPresenter, point, calculateBufferFromPixelTolerance(),
						ServerFeatureService.QueryType.INTERSECTS,
						ServerFeatureService.SearchLayerType.SEARCH_ALL_LAYERS, -1, new SelectionCallback()
				);

	}

}
 
Example 2
@Override
public void onMouseDown(MouseDownEvent event) {
	this.onMouseUp(null);

	Icon dragIcon = (Icon) event.getSource();
	this.selectedRow = (TableRow<T>) dragIcon.getParent().getParent();
	this.body = (TableEditorBody<T>) this.selectedRow.getParent();

	this.overRegistration = new HandlerRegistrationCollection();
	this.upRegistration = RootPanel.get().addDomHandler(this, MouseUpEvent.getType());
	this.rows = Lists.newArrayList(this.body.getRows());
	for (TableRow<T> row : this.rows) {
		this.overRegistration.add(row.addDomHandler(this, MouseOverEvent.getType()));
	}
	TableOrder.this.disableTextSelection(true);
	RootPanel.get().getElement().getStyle().setCursor(Style.Cursor.MOVE);
	StyleUtils.addStyle(this.selectedRow, TableOrder.STYLE_ROW_DRAGING);
}
 
Example 3
Source Project: gantt   Source File: GanttWidget.java    License: 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 4
Source Project: EasyML   Source File: DiagramController.java    License: 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 5
Source Project: EasyML   Source File: MonitorController.java    License: 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 6
Source Project: calendar-component   Source File: DateCellContainer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onMouseUp(MouseUpEvent event) {
    if (event.getSource() == clickTargetWidget
            && clickTargetWidget instanceof WeeklyLongItemsDateCell
            && !calendar.isDisabled()) {
        CalendarItem calendarItem = ((WeeklyLongItemsDateCell) clickTargetWidget)
                .getItem();
        if (calendar.getItemClickListener() != null) {
            calendar.getItemClickListener().itemClick(calendarItem);
        }
    }
}
 
Example 7
Source Project: calendar-component   Source File: DateCell.java    License: 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 8
Source Project: cuba   Source File: CubaDateCell.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onMouseUp(MouseUpEvent event) {
    // consider that rangeSelect will be fired
    rangeSelect = true;

    super.onMouseUp(event);
}
 
Example 9
Source Project: djvu-html5   Source File: PanListener.java    License: GNU General Public License v2.0 5 votes vote down vote up
public PanListener(Widget widget) {
	this.widget = widget;
	widget.addDomHandler(this, MouseDownEvent.getType());
	widget.addDomHandler(this, MouseUpEvent.getType());
	widget.addDomHandler(this, MouseMoveEvent.getType());
	widget.addDomHandler(this, TouchStartEvent.getType());
	widget.addDomHandler(this, TouchEndEvent.getType());
	widget.addDomHandler(this, TouchMoveEvent.getType());
}
 
Example 10
Source Project: swellrt   Source File: PopupMenu.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a {@PopupMenuItem}
 *
 * @param text The text label for the item.
 * @param cmd The command to run when the item is clicked.
 * @param isEnabled True if this menu item is enabled.
 * @param hide True if clicking this menu item should hide the popup.
 */
public PopupMenuItem(String text, Command cmd, boolean isEnabled, boolean hide) {
  super(text);
  setStyleName(RESOURCES.css().item());
  setEnabled(isEnabled);
  defaultEnabled = isEnabled;
  command = cmd;
  this.hide = hide;
  if (isPreClicked) {
    // If this menu is pre-clicked it doesn't require a full click to select
    // an item, just a mouseup over the item.  If the user then does click the
    // item then that will also give a mouseup so this handler will deal with
    // that case as well.
    addMouseUpHandler(new MouseUpHandler() {
      @Override
      public void onMouseUp(MouseUpEvent event) {
        onClicked();
      }
    });
  } else {
    addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent e) {
        onClicked();
      }
    });
  }
  // Ensure that clicking this menu item doesn't affect the current selection.
  addMouseDownHandler(PREVENT_DEFAULT_HANDLER);
}
 
Example 11
@Override
public void onMouseUp(MouseUpEvent event) {
	if (this.upRegistration != null) {
		this.upRegistration.removeHandler();
	}
	if (this.overRegistration != null) {
		this.overRegistration.removeHandler();
	}
	if (this.selectedRow != null) {
		StyleUtils.removeStyle(this.selectedRow, TableOrder.STYLE_ROW_DRAGING);
	}
	this.upRegistration = null;
	this.overRegistration = null;

	if (event != null) {
		event.stopPropagation();
		if (!Iterables.elementsEqual(this.rows, this.body.getRows())) {
			EventBus.get().fireEventFromSource(new RowOrderChangeEvent(this.body), TableOrder.this);
			this.body.setRowOrderDirty(true);
		}
	}

	this.body = null;
	this.hoverRow = null;
	this.selectedRow = null;
	TableOrder.this.disableTextSelection(false);

	RootPanel.get().getElement().getStyle().clearCursor();
}
 
Example 12
Source Project: incubator-retired-wave   Source File: PopupMenu.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a {@PopupMenuItem}
 *
 * @param text The text label for the item.
 * @param cmd The command to run when the item is clicked.
 * @param isEnabled True if this menu item is enabled.
 * @param hide True if clicking this menu item should hide the popup.
 */
public PopupMenuItem(String text, Command cmd, boolean isEnabled, boolean hide) {
  super(text);
  setStyleName(RESOURCES.css().item());
  setEnabled(isEnabled);
  defaultEnabled = isEnabled;
  command = cmd;
  this.hide = hide;
  if (isPreClicked) {
    // If this menu is pre-clicked it doesn't require a full click to select
    // an item, just a mouseup over the item.  If the user then does click the
    // item then that will also give a mouseup so this handler will deal with
    // that case as well.
    addMouseUpHandler(new MouseUpHandler() {
      @Override
      public void onMouseUp(MouseUpEvent event) {
        onClicked();
      }
    });
  } else {
    addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent e) {
        onClicked();
      }
    });
  }
  // Ensure that clicking this menu item doesn't affect the current selection.
  addMouseDownHandler(PREVENT_DEFAULT_HANDLER);
}
 
Example 13
Source Project: circuitjs1   Source File: CirSim.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void onMouseUp(MouseUpEvent e) {
	e.preventDefault();
	mouseDragging=false;
	
	// click to clear selection
	if (tempMouseMode == MODE_SELECT && selectedArea == null)
	    clearSelection();

	// cmd-click = split wire
	if (tempMouseMode == MODE_DRAG_POST && draggingPost == -1)
	    doSplit(mouseElm);
	
	tempMouseMode = mouseMode;
	selectedArea = null;
	dragging = false;
	boolean circuitChanged = false;
	if (heldSwitchElm != null) {
		heldSwitchElm.mouseUp();
		heldSwitchElm = null;
		circuitChanged = true;
	}
	if (dragElm != null) {
		// if the element is zero size then don't create it
		// IES - and disable any previous selection
	    	if (dragElm.creationFailed()) {
			dragElm.delete();
			if (mouseMode == MODE_SELECT || mouseMode == MODE_DRAG_SELECTED)
				clearSelection();
		}
		else {
			elmList.addElement(dragElm);
			dragElm.draggingDone();
			circuitChanged = true;
			writeRecoveryToStorage();
		}
		dragElm = null;
	}
	if (circuitChanged)
		needAnalyze();
	if (dragElm != null)
		dragElm.delete();
	dragElm = null;
	repaint();
}
 
Example 14
/**
 * Add a widget on the diagram
 * 
 * @param w the widget to add
 * @param left left margin with the absolute panel
 * @param top top margin with the absolute panel
 * 
 * @return the shape
 */
public FunctionShape addWidget(final Widget w, int left, int top) {

	w.getElement().getStyle().setZIndex(3);
	final FunctionShape shape = new FunctionShape(this, w);

	shapes.add(shape);
	widgetShapeMap.put(w, shape);
	functionsMap.put(w, new HashMap<Widget, Connection>());

	if (w instanceof HasContextMenu) {
		w.addDomHandler(new MouseUpHandler() {
			@Override
			public void onMouseUp(MouseUpEvent event) {
				if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
					showMenu((HasContextMenu) w, event.getClientX(), event.getClientY());
				}
			}
		}, MouseUpEvent.getType());
	}
	widgetPanel.add(w, left, top);

	// Register the drag handler
	if (dragController != null) {
		registerDragHandler(shape);
	}

	// If the is mouse is over the widget, clear the topCanvas
	w.addDomHandler(new MouseOverHandler() {
		@Override
		public void onMouseOver(com.google.gwt.event.dom.client.MouseOverEvent arg0) {
			topCanvas.clear();
			mousePoint.setLeft(-30);
			mousePoint.setTop(-30);
		}
	}, com.google.gwt.event.dom.client.MouseOverEvent.getType());
	shape.draw();

	// Send event
	handlerManager.fireEvent(new NewFunctionEvent(w));
	return shape;
}
 
Example 15
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 16
Source Project: calendar-component   Source File: DateCell.java    License: 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();
    }
}
 
Example 17
Source Project: appinventor-extensions   Source File: HandlerPanel.java    License: Apache License 2.0 4 votes vote down vote up
public HandlerRegistration addMouseUpHandler(MouseUpHandler handler) {
  return addDomHandler(handler, MouseUpEvent.getType());
}
 
Example 18
Source Project: unitime   Source File: P.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public HandlerRegistration addMouseUpHandler(MouseUpHandler handler) {
	return addHandler(handler, MouseUpEvent.getType());
}
 
Example 19
Source Project: djvu-html5   Source File: PanListener.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onMouseUp(MouseUpEvent event) {
	isMouseDown = false;
	Event.releaseCapture(widget.getElement());
}
 
Example 20
Source Project: djvu-html5   Source File: Scrollbar.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onMouseUp(MouseUpEvent event) {
	super.onMouseUp(event);
	removeStyleName("scrollbarClicked");
}
 
Example 21
Source Project: swellrt   Source File: IconButtonTemplate.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onMouseUp(MouseUpEvent event) {
  mouseListener.onMouseUp();
}
 
Example 22
Source Project: swellrt   Source File: ClickableDivPanel.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public HandlerRegistration addMouseUpHandler(MouseUpHandler handler) {
  return addDomHandler(handler, MouseUpEvent.getType());
}
 
Example 23
@Override
public com.google.gwt.event.shared.HandlerRegistration addMouseUpHandler(MouseUpHandler handler) {
	return this.addDomHandler(handler, MouseUpEvent.getType());
}
 
Example 24
@Override
public HandlerRegistration addMouseUpHandler(MouseUpHandler handler) {
	return this.addDomHandler(handler, MouseUpEvent.getType());
}
 
Example 25
@Override
public void onMouseUp(MouseUpEvent event) {
	this.focusOnCursor();
}
 
Example 26
@Override
public HandlerRegistration addMouseUpHandler(MouseUpHandler handler) {
	return this.addDomHandler(handler, MouseUpEvent.getType());
}
 
Example 27
@Override
public void showSuggestions(Oracle.Request request, final IsWidget textInput,
	Collection<? extends Suggestion<T>> suggestions, final SuggestionCallback<T> callback) {

	boolean anySuggestions = suggestions != null && !suggestions.isEmpty();
	if (!anySuggestions && this.hideWhenEmpty) {
		this.hideSuggestions();
		return;
	}

	if (this.suggestionPopup.isAttached()) {
		this.suggestionPopup.hide();
	}

	this.suggestionsContainer.clear();

	SuggestionItem<T> selected = null;
	for (final Oracle.Suggestion<T> currentSuggestion : suggestions) {
		String display = highlighter.highlight(currentSuggestion.getValue(), request.getQuery());
		final SuggestionItem<T> suggestionItem = new SuggestionItem<T>(currentSuggestion, display);
		if (selected == null) {
			selected = suggestionItem;
		}
		if (this.selectedItem != null && currentSuggestion.equals(this.selectedItem.suggestion)) {
			selected = suggestionItem;
		}

		suggestionItem.addDomHandler(new MouseUpHandler() {
			@Override
			public void onMouseUp(MouseUpEvent event) {
				if (textInput instanceof Focusable) {
					((Focusable) textInput).setFocus(true);
				}
				SuggestionDisplayImpl.this.setSuggestionItemSelected(suggestionItem);
				callback.onSuggestionSelected(suggestionItem.suggestion);
			}
		}, MouseUpEvent.getType());

		this.suggestionsContainer.append(suggestionItem);
	}

	this.setSuggestionItemSelected(selected);

	if (this.lastTextInput != textInput) {
		if (this.lastTextInput != null) {
			this.suggestionPopup.removeAutoHidePartner(this.lastTextInput.asWidget().getElement());
		}
		this.lastTextInput = textInput;
		this.suggestionPopup.addAutoHidePartner(this.lastTextInput.asWidget().getElement());
	}

	this.suggestionPopup.showRelativeTo(this.lastTextInput.asWidget());
	this.scrollToSelected();
}
 
Example 28
Source Project: gantt   Source File: GanttWidget.java    License: 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 29
Source Project: incubator-retired-wave   Source File: IconButtonTemplate.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onMouseUp(MouseUpEvent event) {
  mouseListener.onMouseUp();
}
 
Example 30
Source Project: incubator-retired-wave   Source File: ClickableDivPanel.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public HandlerRegistration addMouseUpHandler(MouseUpHandler handler) {
  return addDomHandler(handler, MouseUpEvent.getType());
}