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

The following are top voted examples for showing how to use com.google.gwt.event.dom.client.MouseDownEvent. 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: drools-wb   File: ListBoxSingletonDOMElementFactoryTest.java   Source Code and License 8 votes vote down vote up
@Test
public void checkDOMElementCreationMouseDownHandler() {
    factory.createDomElement(gridLayer,
                             gridWidget,
                             cellRenderContext);

    final ArgumentCaptor<MouseDownHandler> mouseDownHandlerCaptor = ArgumentCaptor.forClass(MouseDownHandler.class);

    verify(listBox).addMouseDownHandler(mouseDownHandlerCaptor.capture());

    final MouseDownEvent e = mock(MouseDownEvent.class);
    final MouseDownHandler mouseDownHandler = mouseDownHandlerCaptor.getValue();
    mouseDownHandler.onMouseDown(e);

    verify(e).stopPropagation();
}
 
Example 2
Project: vaadin-combobox-multiselect   File: VComboBoxMultiselect.java   Source Code and License 7 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {
	debug("VComboBoxMultiselect.onMouseDown(): blocking mouseDown event to avoid blur");

	event.preventDefault();
	event.stopPropagation();

	/*
	 * In IE the above wont work, the blur event will still trigger. So, we
	 * set a flag here to prevent the next blur event from happening. This
	 * is not needed if do not already have focus, in that case there will
	 * not be any blur event and we should not cancel the next blur.
	 */
	if (BrowserInfo.get()
		.isIE() && this.focused) {
		this.preventNextBlurEventInIE = true;
		debug("VComboBoxMultiselect: Going to prevent next blur event on IE");
	}
}
 
Example 3
Project: vaadin-combobox-multiselect   File: VComboBoxMultiselect.java   Source Code and License 7 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {
	debug("VComboBoxMultiselect.onMouseDown(): blocking mouseDown event to avoid blur");

	event.preventDefault();
	event.stopPropagation();

	/*
	 * In IE the above wont work, the blur event will still trigger. So, we
	 * set a flag here to prevent the next blur event from happening. This
	 * is not needed if do not already have focus, in that case there will
	 * not be any blur event and we should not cancel the next blur.
	 */
	if (BrowserInfo.get()
		.isIE() && this.focused) {
		this.preventNextBlurEventInIE = true;
		debug("VComboBoxMultiselect: Going to prevent next blur event on IE");
	}
}
 
Example 4
Project: hexa.tools   File: ResizablePanelBad.java   Source Code and License 7 votes vote down vote up
@Override
public void onMouseDown( MouseDownEvent event )
{
	direction = getDirection( event.getNativeEvent().getEventTarget() );
	if( direction == 0 )
		return;

	startX = event.getScreenX();
	startY = event.getScreenY();

	startLeft = ResizablePanelBad.this.getAbsoluteLeft();
	startTop = ResizablePanelBad.this.getAbsoluteTop();
	startWidth = ResizablePanelBad.this.getOffsetWidth();
	startHeight = ResizablePanelBad.this.getOffsetHeight();

	DOM.setCapture( getElement() );

	fResizing = true;

	event.stopPropagation();
	event.preventDefault();
}
 
Example 5
Project: putnami-web-toolkit   File: TableOrder.java   Source Code and License 7 votes vote down vote up
@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 6
Project: gantt   File: GanttWidget.java   Source Code and License 7 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {
    GWT.log("onMouseDown(MouseDownEvent)");
    if (event.getNativeButton() == NativeEvent.BUTTON_LEFT) {
        GanttWidget.this.onTouchOrMouseDown(event.getNativeEvent());
    } else {
        secondaryClickOnNextMouseUp = true;
        new Timer() {

            @Override
            public void run() {
                secondaryClickOnNextMouseUp = false;
            }
        }.schedule(CLICK_INTERVAL);
        event.stopPropagation();
    }
}
 
Example 7
Project: geomajas-project-client-gwt   File: LineStringEditController.java   Source Code and License 7 votes vote down vote up
public void onMouseDown(MouseDownEvent event) {
	FeatureTransaction featureTransaction = getFeatureTransaction();
	if (featureTransaction != null && parent.getEditMode() == EditMode.DRAG_MODE
			&& event.getNativeButton() != Event.BUTTON_RIGHT) {
		String targetId = getTargetId(event);
		if (TransactionGeomIndexUtil.isVertex(targetId)) {
			dragTargetId = targetId;
			if (dragTransaction == null) {
				dragTransaction = (FeatureTransaction) featureTransaction.clone();
			}
			mapWidget.render(featureTransaction, RenderGroup.VECTOR, RenderStatus.DELETE);
			mapWidget.render(dragTransaction, RenderGroup.VECTOR, RenderStatus.ALL);
			createTempLine(featureTransaction, event);
		}
	}
}
 
Example 8
Project: geomajas-project-client-gwt   File: PolygonEditController.java   Source Code and License 7 votes vote down vote up
public void onMouseDown(MouseDownEvent event) {
	FeatureTransaction featureTransaction = getFeatureTransaction();
	if (featureTransaction != null && parent.getEditMode() == EditMode.DRAG_MODE
			&& event.getNativeButton() != Event.BUTTON_RIGHT) {
		String targetId = getTargetId(event);
		if (TransactionGeomIndexUtil.isVertex(targetId)) {
			dragTargetId = targetId;
			if (dragTransaction == null) {
				dragTransaction = (FeatureTransaction) featureTransaction.clone();
			}
			mapWidget.render(featureTransaction, RenderGroup.VECTOR, RenderStatus.DELETE);
			mapWidget.render(dragTransaction, RenderGroup.VECTOR, RenderStatus.ALL);
			createTempLines(featureTransaction, event);
		}
	}
}
 
Example 9
Project: EasyML   File: DiagramController.java   Source Code and License 6 votes vote down vote up
/**
 * Trigger action when mouse down event fired
 * 
 * @param event
 */
public void onMouseDown(MouseDownEvent event) {
	logger.info("diagram left mouse down");
	this.getWidgetPanel().getElement().focus();
	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();
		}
		if(isvacancy){
			event.stopPropagation();
			event.preventDefault();
			//Popup connection menu
			if( !this.inShapeArea ){
				final Connection c = getConnectionNearMouse();
				if (c != null) {
					showMenu(c);
				}else{
					showContextualMenu(event);
				}
			}

		}

		return;
	}

	if (!lockDrawConnection && inEditionToDrawConnection) {
		logger.info( "draw connection lock: " +  lockDrawConnection );
		inDragBuildConnection = true;
		inEditionToDrawConnection = false;
		((NodeShape) startShape).onConnectionStart();
		drawBuildArrow(startShape, getMousePoint());
	}
	if(!isvacancy){
		event.stopPropagation();
		event.preventDefault();
		focusTimer.scheduleRepeating(50);
	}
	else {
		this.clearSelectedWidgets();
		selectedWidget = null;
		focusTimer.scheduleRepeating(50);
	}
	this.setIsVacancy(true);
}
 
Example 10
Project: EasyML   File: DiagramController.java   Source Code and License 6 votes vote down vote up
/**
 * Show the context menu of the mouse position.(Position from mouse down event)
 * 
 * @param event  mouse down event.
 */
public void showContextualMenu(MouseDownEvent event){
	final int X = event.getRelativeX(widgetPanel.getElement());
	final int Y = event.getRelativeY(widgetPanel.getElement());
	getMousePoint().setLeft(X);
	getMousePoint().setTop(Y);

	final int offsetX = event.getClientX();
	final int offsetY = event.getClientY();
	mouseOffsetPoint.setLeft(offsetX);
	mouseOffsetPoint.setTop(offsetY);

	cmenu.hide();
	cmenu = new ContextMenu();
	Command command = new Command() {
		@Override
		public void execute() {
			cmenu.hide();
		}
	};
}
 
Example 11
Project: EasyML   File: Leaf.java   Source Code and License 6 votes vote down vote up
/**
 * Create a leaf node for the Tree
 *
 * @param name   name of the TreeItem
 * @param module Attached moduleId for the TreeItem
 */
public Leaf(String name,
		T module,
		String style) {
	// add context menu
	this.menu = new ContextMenu();
	label = new Label(name);
	this.setWidget(label);

	label.addMouseDownHandler(new MouseDownHandler() {
		@Override
		public void onMouseDown(MouseDownEvent event) {
			// display the context menu when right click
			if (event.getNativeButton() == NativeEvent.BUTTON_RIGHT) {
				menu.setPopupPosition(event.getClientX(), event.getClientY());
				menu.show();
			}
		}
	});

	// set moduleId
	this.module = module;
	this.addStyleName("bda-treeleaf");
	if (!style.equals(""))
		this.addStyleName(style);
}
 
Example 12
Project: unitimes   File: RoomSharingWidget.java   Source Code and License 6 votes vote down vote up
Cell(int day, int slot) {
	super("cell", "item", isEditable(day, slot) ? "clickable" : null);
	iDay = day; iSlot = slot;
	RoomSharingOption option = iModel.getOption(day, slot);
	if (option == null) {
		getElement().getStyle().clearBackgroundColor();
		setHTML("");
		setTitle("");
	} else {
		getElement().getStyle().setBackgroundColor(option.getColor());
		setHTML(option.getCode() == null ? "" : option.getCode());
		setTitle(CONSTANTS.longDays()[day] + " " + slot2short(slot) + " - " + slot2short(slot + iMode.getStep()) + ": " + option.getName());
	}
	if (isEditable(day, slot))
		addMouseDownHandler(new MouseDownHandler() {
			@Override
			public void onMouseDown(MouseDownEvent event) {
				setOption(iOption);
			}
		});
}
 
Example 13
Project: unitimes   File: PeriodPreferencesWidget.java   Source Code and License 6 votes vote down vote up
Cell(int day, int slot, Date date, PeriodInterface period) {
	super("cell", "item", isEditable() && period != null ? "clickable" : null, period == null ? "disabled" : null, period != null && iModel.isAssigned(period) ? "highlight" : null);
	iDay = day;
	iSlot = slot;
	iDate = date;
	iPeriod = period;
	if (period != null) {
		PreferenceInterface preference = iModel.getPreference(day, slot);
		if (preference == null) {
			getElement().getStyle().clearBackgroundColor();
			setHTML("");
			setTitle("");
		} else {
			getElement().getStyle().setBackgroundColor(preference.getColor());
			setTitle(DateTimeFormat.getFormat(CONSTANTS.examPeriodDateFormat()).format(date) + " " + slot2short(slot) + (period == null ? "" : " - " + slot2short(slot + period.getLength())) + ": " + preference.getName());
		}
		if (isEditable())
			addMouseDownHandler(new MouseDownHandler() {
				@Override
				public void onMouseDown(MouseDownEvent event) {
					setOption(iPreference);
				}
			});				
	}
}
 
Example 14
Project: unitimes   File: PeriodPreferencesWidget.java   Source Code and License 6 votes vote down vote up
private D(int day, int slot, Date date, PeriodInterface period) {
	super("cell", "day", isEditable() && period != null ? "clickable" : null, period == null ? "unavailable" : null);
	iDay = day;
	iSlot = slot;
	iDate = date;
	iPeriod = period;
	setText(DateTimeFormat.getFormat("d").format(date));
	if (period != null) {
		PreferenceInterface preference = iModel.getPreference(day, slot);
		if (preference == null) {
			getElement().getStyle().clearBackgroundColor();
			setTitle("");
		} else {
			getElement().getStyle().setBackgroundColor(preference.getColor());
			setTitle(DateTimeFormat.getFormat(CONSTANTS.examPeriodDateFormat()).format(date) + " " + slot2short(slot) + (period == null ? "" : " - " + slot2short(slot + period.getLength())) + ": " + preference.getName());
		}
		if (isEditable())
			addMouseDownHandler(new MouseDownHandler() {
				@Override
				public void onMouseDown(MouseDownEvent event) {
					setOption(iPreference);
				}
			});				
	}
}
 
Example 15
Project: unitimes   File: TimeGrid.java   Source Code and License 6 votes vote down vote up
public SelectionPanel(boolean fixed) {
	setStyleName(fixed ? "selection" : "active-selection");
	if (fixed) {
		iRemove = new P("x"); iRemove.setHTML("&times;");
		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 16
Project: appinventor-extensions   File: SimplePaletteItem.java   Source Code and License 6 votes vote down vote up
private void addHandlers() {
  addMouseDownHandler(new MouseDownHandler() {
    @Override
    public void onMouseDown(MouseDownEvent arg0) {
      select(getWidget());
    }
  });
}
 
Example 17
Project: WebConsole   File: ListPanelComponent.java   Source Code and License 6 votes vote down vote up
private void registerHandlers() {
	if(BrowserUtils.isMobile) {
		registerHandler(this.addDomHandler(this, TouchStartEvent.getType()));
		registerHandler(this.addDomHandler(this, TouchEndEvent.getType()));
	} else {
		registerHandler(this.addDomHandler(this, MouseDownEvent.getType()));
		registerHandler(this.addDomHandler(this, MouseUpEvent.getType()));
		registerHandler(this.addDomHandler(this, MouseOutEvent.getType()));
	}
	registerHandler(this.addHandler(this, DragStartEvent.getType()));
	registerHandler(this.addHandler(this, DragMoveEvent.getType()));
	registerHandler(this.addHandler(this, DragEndEvent.getType()));
	registerHandler(this.addHandler(this, DragCancelEvent.getType()));
}
 
Example 18
Project: WebConsole   File: ListPanelComponent.java   Source Code and License 6 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {
	event.stopPropagation();
	startEvent = new PressStartEvent(event);
	eventBus.fireEvent(startEvent);
	this.fireEvent(startEvent);
}
 
Example 19
Project: WebConsole   File: InteractiveConsoleComponent.java   Source Code and License 6 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {
	event.stopPropagation();
	//event.preventDefault();
	startEvent = new PressStartEvent(event);
	eventBus.fireEvent(startEvent);
	this.fireEvent(startEvent);
}
 
Example 20
Project: WebConsole   File: TabBarComponent.java   Source Code and License 6 votes vote down vote up
private TabBarItemComponent createSystemTabItem(EnumSystemTabItemType itemType) {
	TabBarItem tabBarItem = null;
	TabBarItemComponent component = null;
	AutoBean<TabBarItem> TabBarItemBean = AutoBeanService.getInstance().getFactory().tabBarItem();
	tabBarItem = TabBarItemBean.as();
	switch (itemType) {
		case PREVIOUS:
			tabBarItem.setName("<");
			break;
		case NEXT:
			tabBarItem.setName(">");
			break;
	}
	component = new TabBarItemComponent(tabBarItem, itemType);
	// Add handlers as not created by usual mechanism
	if(BrowserUtils.isMobile) {
		systemTabHandlers.add(component.addDomHandler(this, TouchStartEvent.getType()));
		systemTabHandlers.add(component.addDomHandler(this, TouchEndEvent.getType()));
	} else {
		systemTabHandlers.add(component.addDomHandler(this, MouseDownEvent.getType()));
		systemTabHandlers.add(component.addDomHandler(this, MouseUpEvent.getType()));
		systemTabHandlers.add(component.addDomHandler(this, MouseOutEvent.getType()));
	}
	systemTabHandlers.add(component.addHandler(component, TapEvent.getType()));
	return component;
}
 
Example 21
Project: LAS   File: WindowBox.java   Source Code and License 6 votes vote down vote up
@Override
protected void beginDragging(MouseDownEvent event) {
	int dm = -1;
	
	if (this.resizable && !this.minimized)
		dm = this.calcDragMode(event.getClientX(),event.getClientY());
	
	if (this.resizable && dm >= 0) {
		this.dragMode = dm;
		
		DOM.setCapture(getElement());
		
		this.dragX = event.getClientX();
		this.dragY = event.getClientY();
		
		updateCursor(dm,RootPanel.get().getElement());
		
	} else {
		super.beginDragging(event);
	}
}
 
Example 22
Project: Wiab.pro   File: BlipIndicatorController.java   Source Code and License 6 votes vote down vote up
@Override
public boolean onMouseDown(MouseDownEvent event, Element context) {
  Element metaElement = context.getParentElement();
  Element blipElement = metaElement.getParentElement();
  BlipView blipView = viewProvider.asBlip(blipElement);
  ConversationBlip blip = modelProvider.getBlip(blipView);
  reader.read(blip);
  
  event.stopPropagation();
  return true;
}
 
Example 23
Project: Wiab.pro   File: ReplyIndicatorController.java   Source Code and License 6 votes vote down vote up
@Override
public boolean onMouseDown(MouseDownEvent event, Element context) {
  if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
    return false;
  }

  ReplyBoxView indicatorView = panel.asReplyBox(context);
  ThreadView threadView = indicatorView.getParent();
  ConversationThread thread = modelAsViewProvider.getThread(threadView);
  actions.addBlipToThread(thread);
  event.preventDefault();
  return true;
}
 
Example 24
Project: Wiab.pro   File: FocusFrameController.java   Source Code and License 6 votes vote down vote up
@Override
public boolean onMouseDown(MouseDownEvent event, Element source) {
  if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
    return false;
  }
  BlipView blipView = panel.asBlip(source);
  ConversationBlip blip = modelAsViewProvider.getBlip(blipView);
  focus.focus(blip);    
  return true;
}
 
Example 25
Project: Wiab.pro   File: CollapseController.java   Source Code and License 6 votes vote down vote up
@Override
public boolean onMouseDown(MouseDownEvent event, Element source) {
  if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
    return false;
  }
  handleClick(panel.fromToggle(source));
  return false;
}
 
Example 26
Project: ephesoft   File: FolderTableView.java   Source Code and License 6 votes vote down vote up
private void addHandlersToFileIconedName(final FileWrapper file, final String fileName, HTML fileIconedName) {
	fileIconedName.addMouseDownHandler(new MouseDownHandler() {

		@Override
		public void onMouseDown(MouseDownEvent mouseDown) {
			presenter.setSelectedFile(file);
			com.google.gwt.user.client.Timer timer = new com.google.gwt.user.client.Timer() {

				@Override
				public void run() {
					presenter.setSelectedFile(null);
				}
			};
			timer.schedule(500);
			if (mouseDown.getNativeButton() == Event.BUTTON_RIGHT) {
				performOperationsOnRightClick(file, fileName, mouseDown);
			}
		}

	});
}
 
Example 27
Project: che   File: View.java   Source Code and License 6 votes vote down vote up
private void beginDragging(MouseDownEvent event) {
  if (DOM.getCaptureElement() == null) {
    /*
     * Need to check to make sure that we aren't already capturing an element
     * otherwise events will not fire as expected. If this check isn't here,
     * any class which extends custom button will not fire its click event for
     * example.
     */
    dragging = true;
    DOM.setCapture(header.getElement());
    if ("".equals(contentContainer.getElement().getStyle().getPosition())) {
      contentContainer
          .getElement()
          .getStyle()
          .setTop(contentContainer.getAbsoluteTop() + 1, Style.Unit.PX);
      contentContainer
          .getElement()
          .getStyle()
          .setLeft(contentContainer.getAbsoluteLeft(), Style.Unit.PX);
    } else {
      contentContainer
          .getElement()
          .getStyle()
          .setTop(contentContainer.getAbsoluteTop(), Style.Unit.PX);
      contentContainer
          .getElement()
          .getStyle()
          .setLeft(contentContainer.getAbsoluteLeft(), Style.Unit.PX);
    }

    contentContainer.getElement().getStyle().setPosition(Style.Position.ABSOLUTE);
    elemental.dom.Element element = (elemental.dom.Element) contentContainer.getElement();
    transition = element.getStyle().getPropertyValue("transition");
    element.getStyle().setProperty("transition", "all 0ms");

    dragStartX = event.getX();
    dragStartY = event.getY();
  }
}
 
Example 28
Project: che   File: SelectionModel.java   Source Code and License 6 votes vote down vote up
public void bindTree(Tree tree) {
  if (this.tree != null) {
    handlerRegistration.removeHandler();
    keyNav.bind(null);
    bindStorage(null);
    nodeStorage = null;
  }

  this.tree = tree;

  if (tree != null) {
    if (handlerRegistration == null) {
      handlerRegistration = new GroupingHandlerRegistration();
    }
    handlerRegistration.add(tree.addDomHandler(treeMouseHandler, MouseDownEvent.getType()));
    handlerRegistration.add(tree.addDomHandler(treeMouseHandler, ClickEvent.getType()));
    keyNav.bind(tree);
    bindStorage(tree.getNodeStorage());
    nodeStorage = tree.getNodeStorage();
  }
}
 
Example 29
Project: riscoss-corporate   File: IndicatorWidget.java   Source Code and License 6 votes vote down vote up
protected void mousePressed(MouseDownEvent event) {
	int bar = findBar( event.getX(), event.getY() );
	if( bar == -1 ) return;
	double val = findValue( bar, event.getY() );
	List<Double> v = distribution.getValues();
	v.set( bar, val );
	distribution.flatten( bar );
	distribution.setValues( v ); // not needed because distribution.getValues() returns a reference
	this.bars = mkBars( distribution, mleft, mtop, canvas.getCoordinateSpaceWidth() -(mleft + mright), canvas.getCoordinateSpaceHeight() -(mtop + mbottom) );
	Context2d g = canvas.getContext2d();
	g.clearRect( 0, 0, canvas.getCoordinateSpaceWidth(), canvas.getCoordinateSpaceHeight() );
	paint( distribution, g, mleft, mtop, canvas.getCoordinateSpaceWidth() -(mleft + mright), canvas.getCoordinateSpaceHeight() -(mtop + mbottom) );
	for( Listener l : listeners ) {
		l.IndicatorValueChanged();
	}
}
 
Example 30
Project: firefly   File: WebPlotView.java   Source Code and License 6 votes vote down vote up
/**
 * Create a new PlotView.  This constructor is typically used when the
 * PlotView <em>will</em> be placed insides a scrolled window.
 */
public WebPlotView() {
    initWidgets();
    _scrollingRootPanel.addDomHandler(new MouseDownHandler() {
        public void onMouseDown(MouseDownEvent ev) {
            if (_mpw != null) _mpw.selectSelf();
        }
    }, MouseDownEvent.getType());

    _scrollingRootPanel.addDomHandler(new TouchStartHandler() {
        public void onTouchStart(TouchStartEvent event) {
            if (_mpw != null) _mpw.selectSelf();
        }
    }, TouchStartEvent.getType());

}
 
Example 31
Project: unitime   File: RoomSharingWidget.java   Source Code and License 6 votes vote down vote up
Cell(int day, int slot) {
	super("cell", "item", isEditable(day, slot) ? "clickable" : null);
	iDay = day; iSlot = slot;
	RoomSharingOption option = iModel.getOption(day, slot);
	if (option == null) {
		getElement().getStyle().clearBackgroundColor();
		setHTML("");
		setTitle("");
	} else {
		getElement().getStyle().setBackgroundColor(option.getColor());
		setHTML(option.getCode() == null ? "" : option.getCode());
		setTitle(CONSTANTS.longDays()[day] + " " + slot2short(slot) + " - " + slot2short(slot + iMode.getStep()) + ": " + option.getName());
	}
	if (isEditable(day, slot))
		addMouseDownHandler(new MouseDownHandler() {
			@Override
			public void onMouseDown(MouseDownEvent event) {
				setOption(iOption);
			}
		});
}
 
Example 32
Project: unitime   File: PeriodPreferencesWidget.java   Source Code and License 6 votes vote down vote up
Cell(int day, int slot, Date date, PeriodInterface period) {
	super("cell", "item", isEditable() && period != null ? "clickable" : null, period == null ? "disabled" : null, period != null && iModel.isAssigned(period) ? "highlight" : null);
	iDay = day;
	iSlot = slot;
	iDate = date;
	iPeriod = period;
	if (period != null) {
		PreferenceInterface preference = iModel.getPreference(day, slot);
		if (preference == null) {
			getElement().getStyle().clearBackgroundColor();
			setHTML("");
			setTitle("");
		} else {
			getElement().getStyle().setBackgroundColor(preference.getColor());
			setTitle(DateTimeFormat.getFormat(CONSTANTS.examPeriodDateFormat()).format(date) + " " + slot2short(slot) + (period == null ? "" : " - " + slot2short(slot + period.getLength())) + ": " + preference.getName());
		}
		if (isEditable())
			addMouseDownHandler(new MouseDownHandler() {
				@Override
				public void onMouseDown(MouseDownEvent event) {
					setOption(iPreference);
				}
			});				
	}
}
 
Example 33
Project: unitime   File: PeriodPreferencesWidget.java   Source Code and License 6 votes vote down vote up
private D(int day, int slot, Date date, PeriodInterface period) {
	super("cell", "day", isEditable() && period != null ? "clickable" : null, period == null ? "unavailable" : null);
	iDay = day;
	iSlot = slot;
	iDate = date;
	iPeriod = period;
	setText(DateTimeFormat.getFormat("d").format(date));
	if (period != null) {
		PreferenceInterface preference = iModel.getPreference(day, slot);
		if (preference == null) {
			getElement().getStyle().clearBackgroundColor();
			setTitle("");
		} else {
			getElement().getStyle().setBackgroundColor(preference.getColor());
			setTitle(DateTimeFormat.getFormat(CONSTANTS.examPeriodDateFormat()).format(date) + " " + slot2short(slot) + (period == null ? "" : " - " + slot2short(slot + period.getLength())) + ": " + preference.getName());
		}
		if (isEditable())
			addMouseDownHandler(new MouseDownHandler() {
				@Override
				public void onMouseDown(MouseDownEvent event) {
					setOption(iPreference);
				}
			});				
	}
}
 
Example 34
Project: unitime   File: TimeGrid.java   Source Code and License 6 votes vote down vote up
public SelectionPanel(boolean fixed) {
	setStyleName(fixed ? "selection" : "active-selection");
	if (fixed) {
		iRemove = new P("x"); iRemove.setHTML("&times;");
		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 35
Project: appformer   File: BaseDOMElement.java   Source Code and License 6 votes vote down vote up
protected void setupDelegatingMouseDownHandler() {
    widgetContainer.addDomHandler(new MouseDownHandler() {
                                      @Override
                                      public void onMouseDown(final MouseDownEvent event) {
                                          gridLayer.onNodeMouseDown(new NodeMouseDownEvent(event) {

                                              @Override
                                              public int getX() {
                                                  //Adjust the x-coordinate (relative to the DOM Element) to be relative to the GridCanvas.
                                                  return super.getX() + widgetContainer.getElement().getOffsetLeft();
                                              }

                                              @Override
                                              public int getY() {
                                                  //Adjust the y-coordinate (relative to the DOM Element) to be relative to the GridCanvas.
                                                  return super.getY() + widgetContainer.getElement().getOffsetTop();
                                              }
                                          });
                                      }
                                  },
                                  MouseDownEvent.getType());
}
 
Example 36
Project: appformer   File: BoundaryMousePanMediatorTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testMouseUpEvent() {
    final MouseDownEvent md0 = mock(MouseDownEvent.class);
    when(md0.getRelativeX(any(Element.class))).thenReturn(0);
    when(md0.getRelativeY(any(Element.class))).thenReturn(0);
    final NodeMouseDownEvent nmd0 = new NodeMouseDownEvent(md0);

    final MouseUpEvent mu0 = mock(MouseUpEvent.class);
    final NodeMouseUpEvent nmu0 = new NodeMouseUpEvent(mu0);

    mediator.handleEvent(nmd0);
    mediator.handleEvent(nmu0);

    verify(vpStyle,
           times(1)).setCursor(eq(Style.Cursor.MOVE));
    verify(vpStyle,
           times(1)).setCursor(eq(Style.Cursor.DEFAULT));
}
 
Example 37
Project: appformer   File: BoundaryMousePanMediatorTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testMouseMoveEvent_RightEdge() {
    final MouseDownEvent md0 = mock(MouseDownEvent.class);
    when(md0.getRelativeX(any(Element.class))).thenReturn(0);
    when(md0.getRelativeY(any(Element.class))).thenReturn(0);
    final NodeMouseDownEvent nmd0 = new NodeMouseDownEvent(md0);

    final MouseMoveEvent mm1 = mock(MouseMoveEvent.class);
    when(mm1.getRelativeX(any(Element.class))).thenReturn(-200);
    when(mm1.getRelativeY(any(Element.class))).thenReturn(0);
    final NodeMouseMoveEvent nmm1 = new NodeMouseMoveEvent(mm1);

    final ArgumentCaptor<Transform> transformArgumentCaptor = ArgumentCaptor.forClass(Transform.class);

    mediator.handleEvent(nmd0);
    mediator.handleEvent(nmm1);

    verify(viewport,
           times(1)).setTransform(transformArgumentCaptor.capture());
    final Transform result = transformArgumentCaptor.getValue();
    assertNotNull(result);
    assertEquals(0.0,
                 result.getTranslateX(),
                 0.0);
    assertEquals(0.0,
                 result.getTranslateY(),
                 0.0);
}
 
Example 38
Project: platypus-js   File: WindowPanel.java   Source Code and License 6 votes vote down vote up
public WindowPanel() {
	super(true);
	addDomHandler(new MouseDownHandler() {

		@Override
		public void onMouseDown(MouseDownEvent event) {
			focus();
		}
	}, MouseDownEvent.getType());
	verticalPanel = new VerticalPanel();
	super.setWidget(verticalPanel);
	setCaptionWidget(new Caption(""));
	setUndecorated(false);
	getElement().addClassName("window-panel");
	getElement().<XElement> cast().addResizingTransitionEnd(this);
	getMovableTarget().getElement().<XElement> cast().addResizingTransitionEnd(this);
}
 
Example 39
Project: platypus-js   File: EventsExecutor.java   Source Code and License 6 votes vote down vote up
public void setMousePressed(JavaScriptObject aValue) {
	if (mousePressed != aValue) {
		if (mouseDownReg != null) {
			mouseDownReg.removeHandler();
			mouseDownReg = null;
		}
		mousePressed = aValue;
		if (mousePressed != null) {
			MouseDownHandler handler = new MouseDownHandler() {
				@Override
				public void onMouseDown(MouseDownEvent event) {
					if (mousePressed != null) {
						event.stopPropagation();
						// Event.setCapture(event.getRelativeElement());
						mouseState = MOUSE.PRESSED;
						executeEvent(mousePressed, EventsPublisher.publish(event));
					}
				}
			};
			if (component instanceof Widget) {
				mouseDownReg = ((Widget) component).addDomHandler(handler, MouseDownEvent.getType());
			} else if (component instanceof HasMouseDownHandlers) {
				mouseDownReg = ((HasMouseDownHandlers) component).addMouseDownHandler(handler);
			}
		}
	}
}
 
Example 40
Project: hexa.tools   File: DialogBoxForNormalWidget.java   Source Code and License 6 votes vote down vote up
@Override
public void onMouseDown( MouseDownEvent event )
{
	if( event.getNativeEvent().getEventTarget().<Element>cast() == title )
	{
		isMoving = true;
		movingMouseOffsetX = event.getClientX();
		movingMouseOffsetY = event.getClientY();

		DOM.setCapture( title );
		event.preventDefault();
		event.stopPropagation();
	}
}
 
Example 41
Project: hexa.tools   File: DynTreeInTreeTable.java   Source Code and License 6 votes vote down vote up
public DynTreeInTreeTable( TreeTable table, TreeRefMng<T> refMng, Resources resources )
{
	if( resources == null )
	{
		if( defaultResources == null )
			defaultResources = GWT.create( DefaultResources.class );

		this.resources = defaultResources;
	}
	else
	{
		this.resources = resources;
	}

	this.table = table;
	this.refMng = refMng;

	table.addTableHeaderClickHandler( tableHeaderClickHandler );
	table.addTableCellClickHandler( tableCellClickHandler );
	table.addDomHandler( onTableKeyUp, KeyDownEvent.getType() );
	table.addDomHandler( onTableMouseDown, MouseDownEvent.getType() );
}
 
Example 42
Project: gantt   File: SvgArrowWidget.java   Source Code and License 6 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {
    if (event.getNativeButton() == NativeEvent.BUTTON_LEFT) {
        GWT.log("Starting point Clicked!");

        handleDownEvent(event.getNativeEvent());
    }
}
 
Example 43
Project: gantt   File: SvgArrowWidget.java   Source Code and License 6 votes vote down vote up
@Override
public void setUpEventHandlers(boolean touchSupported,
        boolean msTouchSupported) {
    this.touchSupported = touchSupported;
    this.msTouchSupported = msTouchSupported;
    if (msTouchSupported) {
        addDomHandler(pointerDownHandler, PointerDownEvent.getType());
        addDomHandler(pointerUpHandler, PointerUpEvent.getType());
    } else if (touchSupported) {
        addDomHandler(touchStartHandler, TouchStartEvent.getType());
    } else {
        addHandler(mouseDownHandler, MouseDownEvent.getType());
    }
    registerMouseDownAndTouchDownEventListener(startingPoint);
    registerMouseDownAndTouchDownEventListener(endingPoint);
}
 
Example 44
Project: QMAClone   File: StrokeCanvas.java   Source Code and License 6 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {
	final int x = event.getX();
	final int y = event.getY();
	// System.out.println("onMouseDown(" + x + "," + y + ")");

	if (lastStroke != null) {
		System.out.println("error : 前のストローク情報が終わらないまま次のストロークが始まった");
	}
	lastStroke = new ArrayList<double[]>();
	addPointToLastStroke(x, y);

	// updateCanvas();
}
 
Example 45
Project: QMAClone   File: InputWidgetClick.java   Source Code and License 6 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {
	if (throughClick) {
		return;
	}

	int x = event.getX();
	int y = event.getY();
	clickPosition = new Point(x, y);
	if (canvas != null) {
		circleMarkId = canvas.addPointerMark(x, y, circleMarkId);
		canvas.update();
	}
}
 
Example 46
Project: ListBuilder   File: VListBuilder.java   Source Code and License 6 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {
	// Ensure that items are deselected when selecting
	// from a different source. See #3699 for details.
	if (event.getSource() == optionsListBox) {
		for (int i = 0; i < selectionsListBox.getItemCount(); i++) {
			selectionsListBox.setItemSelected(i, false);
		}
	} else if (event.getSource() == selectionsListBox) {
		for (int i = 0; i < optionsListBox.getItemCount(); i++) {
			optionsListBox.setItemSelected(i, false);
		}
	}

}
 
Example 47
Project: geomajas-project-client-gwt   File: AbstractCircleController.java   Source Code and License 6 votes vote down vote up
/**
 * Register center point for the circle, and start dragging and rendering.
 * 
 * @param event
 *            event
 */
public void onMouseDown(MouseDownEvent event) {
	if (event.getNativeButton() != NativeEvent.BUTTON_RIGHT) {
		dragging = true;
		center = getScreenPosition(event);

		LineString radiusLine = mapWidget.getMapModel().getGeometryFactory().createLineString(
				new Coordinate[] { center, center });
		mapWidget.getVectorContext().drawGroup(mapWidget.getGroup(RenderGroup.SCREEN), circleGroup);
		mapWidget.getVectorContext().drawCircle(circleGroup, "outer", center, 1.0f, circleStyle);
		mapWidget.getVectorContext().drawCircle(circleGroup, "center", center, 2.0f, circleStyle);
		mapWidget.getVectorContext().drawLine(circleGroup, "radius", radiusLine, circleStyle);
	}
}
 
Example 48
Project: geomajas-project-client-gwt   File: OverviewMapController.java   Source Code and License 6 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {
	if (event.getNativeButton() != NativeEvent.BUTTON_RIGHT) {
		dragging = true;
		oldPosition = getWorldPosition(event);
		previous = getScreenPosition(event);
		mapWidget.setCursor(Cursor.POINTER);
	}
}
 
Example 49
Project: geomajas-project-client-gwt   File: PointEditController.java   Source Code and License 6 votes vote down vote up
public void onMouseDown(MouseDownEvent event) {
	FeatureTransaction featureTransaction = getFeatureTransaction();
	if (featureTransaction != null && parent.getEditMode() == EditMode.DRAG_MODE
			&& event.getNativeButton() != Event.BUTTON_RIGHT) {
		String targetId = getTargetId(event);
		if (TransactionGeomIndexUtil.isDraggable(targetId)) {
			dragTargetId = targetId;
			if (dragTransaction == null) {
				dragTransaction = (FeatureTransaction) featureTransaction.clone();
			}
			mapWidget.render(featureTransaction, RenderGroup.VECTOR, RenderStatus.DELETE);
			mapWidget.render(dragTransaction, RenderGroup.VECTOR, RenderStatus.ALL);
		}
	}
}
 
Example 50
Project: geomajas-project-client-gwt2   File: NavigationController.java   Source Code and License 6 votes vote down vote up
@Override
public void onMouseDown(MouseDownEvent event) {
	super.onMouseDown(event);
	if (event.isControlKeyDown() || event.isShiftKeyDown()) {
		// Trigger the dragging on the zoomToRectangleController:
		zoomToRectangleController.onMouseDown(event);
	}
}
 
Example 51
Project: geomajas-project-client-gwt2   File: ZoomStepControl.java   Source Code and License 6 votes vote down vote up
public void onMouseDown(MouseDownEvent event) {
	dragging = true;
	stretchLayout();
	event.stopPropagation();
	event.preventDefault();
	handleY = handleDragStartY;
	currentY = handleY + event.getY();
}
 
Example 52
Project: geomajas-project-client-gwt2   File: DrawingInteractionPanel.java   Source Code and License 6 votes vote down vote up
public void onMouseDown(MouseDownEvent event) {
	dragging = true;
	startX = event.getX();
	startY = event.getY();

	// Stop the event from reaching the map controller: no panning while we're dragging the rectangle.
	event.stopPropagation();
}
 
Example 53
Project: incubator-wave   File: FocusFrameController.java   Source Code and License 6 votes vote down vote up
@Override
public boolean onMouseDown(MouseDownEvent event, Element source) {
  if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
    return false;
  }
  focus.focusWithoutScroll(panel.asBlip(source));
  // Cancel bubbling, so that other blips do not grab focus.
  return true;
}
 
Example 54
Project: incubator-wave   File: MenuController.java   Source Code and License 6 votes vote down vote up
@Override
public boolean onMouseDown(MouseDownEvent event, Element context) {
  if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
    return false;
  }
  BlipMenuItemView item = panel.asBlipMenuItem(context);
  switch (item.getOption()) {
    case EDIT:
      actions.startEditing(item.getParent().getParent());
      break;
    case EDIT_DONE:
      actions.stopEditing();
      break;
    case REPLY:
      actions.reply(item.getParent().getParent());
      break;
    case DELETE:
      // We delete the blip without confirmation if shift key is pressed
      if (event.getNativeEvent().getShiftKey() || Window.confirm(messages.confirmDeletion())) {
        actions.delete(item.getParent().getParent());
      }
      break;
    case LINK:
      actions.popupLink(item.getParent().getParent());
      break;
    default:
      throw new AssertionError();
  }
  event.preventDefault();
  return true;
}
 
Example 55
Project: incubator-wave   File: CollapseController.java   Source Code and License 6 votes vote down vote up
@Override
public boolean onMouseDown(MouseDownEvent event, Element source) {
  if (event.getNativeButton() != NativeEvent.BUTTON_LEFT) {
    return false;
  }
  handleClick(panel.fromToggle(source));
  return false;
}
 
Example 56
Project: gwt-mousemanager   File: MouseHandlerManager.java   Source Code and License 6 votes vote down vote up
/**
 * Update event caches to keep track of the latest event of each instance.
 * @param the event to cache
 */
private void updateEventCaches(Event<?> event){
	if(event == null){
		return;
	}
	if(event instanceof DoubleClickEvent){
		doubleClickEvent = new org.gz.gwt.mousemanager.client.event.DoubleClickEvent((DoubleClickEvent)event, target);
	}
	if(event instanceof ClickEvent){
		clickEvent = new org.gz.gwt.mousemanager.client.event.ClickEvent((ClickEvent)event, target);
	}		
	if(event instanceof MouseUpEvent){
		mouseUpEvent = new org.gz.gwt.mousemanager.client.event.MouseUpEvent((MouseUpEvent)event, target);
	}
	if(event instanceof MouseDownEvent){
		mouseDownEvent = new org.gz.gwt.mousemanager.client.event.MouseDownEvent((MouseDownEvent)event, target);
	} 
	if(event instanceof MouseMoveEvent){
		mouseMoveEvent = new org.gz.gwt.mousemanager.client.event.MouseMoveEvent((MouseMoveEvent)event, target);
	}
	if(event instanceof MouseOverEvent){
		mouseOverEvent = new org.gz.gwt.mousemanager.client.event.MouseOverEvent((MouseOverEvent)event, target);
	}
	if(event instanceof MouseOutEvent){
		mouseOutEvent = new org.gz.gwt.mousemanager.client.event.MouseOutEvent((MouseOutEvent)event, target);
	}
	if(event instanceof MouseWheelEvent){
		mouseWheelEvent = new org.gz.gwt.mousemanager.client.event.MouseWheelEvent((MouseWheelEvent)event, target);
	}
	if(event instanceof ContextMenuEvent){
		contextMenuEvent = new org.gz.gwt.mousemanager.client.event.ContextMenuEvent();
	}
}
 
Example 57
Project: drools-wb   File: ListBoxSingletonDOMElementFactory.java   Source Code and License 6 votes vote down vote up
@Override
public ListBoxDOMElement<T, W> createDomElement(final GridLayer gridLayer,
                                                final GridWidget gridWidget,
                                                final GridBodyCellRenderContext context) {
    this.widget = createWidget();
    this.widget.addMouseDownHandler(MouseDownEvent::stopPropagation);
    this.widget.addKeyDownHandler(new KeyDownHandlerCommon(gridPanel,
                                                           gridLayer,
                                                           gridWidget,
                                                           this,
                                                           context));
    this.widget.addBlurHandler((e) -> {
        flush();
        destroyResources();
        gridLayer.batch();
        gridPanel.setFocus(true);
    });

    this.e = new ListBoxDOMElement<>(widget,
                                     gridLayer,
                                     gridWidget,
                                     widget.isMultipleSelect());

    return e;
}
 
Example 58
Project: swarm   File: ToolTipManager.java   Source Code and License 6 votes vote down vote up
public ToolTipManager(boolean enabled, int mouseOverDelayMilliseconds)
{
	m_isMouseOverEnabled = enabled;
	
	m_subManagers = new I_ToolTipSubManager[E_ToolTipType.values().length];
	RootPanel.get().addDomHandler(new MouseDownHandler()
	{
		@Override
		public void onMouseDown(MouseDownEvent event)
		{
			for( int i = 0; i < m_subManagers.length; i++ )
			{
				m_subManagers[i].onGlobalMouseDown(event);
			}
		}

	}, MouseDownEvent.getType());
	
	m_subManagers[E_ToolTipType.FOCUS.ordinal()]			= new ToolTipSubManager_Focus(this);
	m_subManagers[E_ToolTipType.MOUSE_OVER.ordinal()]		= new ToolTipSubManager_MouseOver(this, mouseOverDelayMilliseconds);
	m_subManagers[E_ToolTipType.NOTIFICATION.ordinal()]	= new ToolTipSubManager_Notification(this);
	m_subManagers[E_ToolTipType.TUTORIAL.ordinal()]		= new ToolTipSubManager_Tutorial(this);
	m_subManagers[E_ToolTipType.STATUS.ordinal()]			= new ToolTipSubManager_Status(this);
}
 
Example 59
Project: swarm   File: SurfaceView.java   Source Code and License 6 votes vote down vote up
/**
 * @param note
 *          the note to render
 */
public NoteView(Note note) {
  this.note = note;
  setStyleName("note");
  note.setObserver(this);

  final Element elem = getElement();
  elem.getStyle().setProperty("position", "absolute");
  titleElement = elem.appendChild(Document.get().createDivElement());
  titleElement.setClassName("note-title");

  content.setStyleName("note-content");
  content.addValueChangeHandler(this);
  setWidget(content);

  render();

  addDomHandler(this, MouseDownEvent.getType());
  addDomHandler(this, MouseMoveEvent.getType());
  addDomHandler(this, MouseUpEvent.getType());
}
 
Example 60
Project: swarm   File: SurfaceView.java   Source Code and License 6 votes vote down vote up
public void onMouseDown(MouseDownEvent event) {
  SurfaceView.this.select(this);
  if (!note.isOwnedByCurrentUser()) {
    return;
  }

  final EventTarget target = event.getNativeEvent().getEventTarget();
  assert Element.is(target);
  if (!Element.is(target)) {
    return;
  }

  if (titleElement.isOrHasChild(Element.as(target))) {
    dragging = true;
    final Element elem = getElement().cast();
    dragOffsetX = event.getX();
    dragOffsetY = event.getY();
    DOM.setCapture(elem);
    event.preventDefault();
  }
}