@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(); }
/** * 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); }
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); } }); }
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); } }); } }
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); } }); } }
public SelectionPanel(boolean fixed) { setStyleName(fixed ? "selection" : "active-selection"); if (fixed) { iRemove = new P("x"); iRemove.setHTML("×"); 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); }
private void addHandlers() { addMouseDownHandler(new MouseDownHandler() { @Override public void onMouseDown(MouseDownEvent arg0) { select(getWidget()); } }); }
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); } } }); }
/** * 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()); }
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) { return html.addMouseDownHandler(handler); }
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()); }
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); }
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); } } } }
@Before public void setup() { when(gridLayer.addNodeMouseMoveHandler(any(NodeMouseMoveHandler.class))).thenReturn(mock(HandlerRegistration.class)); when(gridLayer.addNodeMouseOutHandler(any(NodeMouseOutHandler.class))).thenReturn(mock(HandlerRegistration.class)); when(view.addKeyDownHandler(any(KeyDownHandler.class))).thenReturn(mock(HandlerRegistration.class)); when(view.addContextMenuHandler(any(ContextMenuHandler.class))).thenReturn(mock(HandlerRegistration.class)); when(view.addMouseDownHandler(any(MouseDownHandler.class))).thenReturn(mock(HandlerRegistration.class)); when(view.getGridLayerView()).thenReturn(gridLayer); when(view.getBounds()).thenReturn(bounds); final GuidedDecisionTableModellerPresenter wrapped = new GuidedDecisionTableModellerPresenter(view, dtablePresenterProvider, contextMenuSupport, updateRadarEvent, pinnedEvent, columnHeaderPopOver, wizardManagedInstance); presenter = spy(wrapped); when(dtablePresenterProvider.get()).thenReturn(dtablePresenter); when(dtablePresenter.getView()).thenReturn(dtableView); when(dtableView.getModel()).thenReturn(new BaseGridData()); }
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); }
/** * Adds the header row to the table. * */ private void setHeaderRow() { table.getRowFormatter().setStyleName(0, "ode-ProjectHeaderRow"); HorizontalPanel nameHeader = new HorizontalPanel(); final Label nameHeaderLabel = new Label(MESSAGES.projectNameHeader()); nameHeaderLabel.addStyleName("ode-ProjectHeaderLabel"); nameHeader.add(nameHeaderLabel); nameSortIndicator.addStyleName("ode-ProjectHeaderLabel"); nameHeader.add(nameSortIndicator); table.setWidget(0, 1, nameHeader); HorizontalPanel dateCreatedHeader = new HorizontalPanel(); final Label dateCreatedHeaderLabel = new Label(MESSAGES.projectDateCreatedHeader()); dateCreatedHeaderLabel.addStyleName("ode-ProjectHeaderLabel"); dateCreatedHeader.add(dateCreatedHeaderLabel); dateCreatedSortIndicator.addStyleName("ode-ProjectHeaderLabel"); dateCreatedHeader.add(dateCreatedSortIndicator); table.setWidget(0, 2, dateCreatedHeader); HorizontalPanel dateModifiedHeader = new HorizontalPanel(); final Label dateModifiedHeaderLabel = new Label(MESSAGES.projectDateModifiedHeader()); dateModifiedHeaderLabel.addStyleName("ode-ProjectHeaderLabel"); dateModifiedHeader.add(dateModifiedHeaderLabel); dateModifiedSortIndicator.addStyleName("ode-ProjectHeaderLabel"); dateModifiedHeader.add(dateModifiedSortIndicator); table.setWidget(0, 3, dateModifiedHeader); HorizontalPanel publishedHeader = new HorizontalPanel(); final Label publishedHeaderLabel = new Label(MESSAGES.projectPublishedHeader()); publishedHeaderLabel.addStyleName("ode-ProjectHeaderLabel"); publishedHeader.add(publishedHeaderLabel); publishedSortIndicator.addStyleName("ode-ProjectHeaderLabel"); publishedHeader.add(publishedSortIndicator); table.setWidget(0, 4, publishedHeader); MouseDownHandler mouseDownHandler = new MouseDownHandler() { @Override public void onMouseDown(MouseDownEvent e) { SortField clickedSortField; if (e.getSource() == nameHeaderLabel || e.getSource() == nameSortIndicator) { clickedSortField = SortField.NAME; } else if (e.getSource() == dateCreatedHeaderLabel || e.getSource() == dateCreatedSortIndicator) { clickedSortField = SortField.DATE_CREATED; } else if (e.getSource() == dateModifiedHeaderLabel || e.getSource() == dateModifiedSortIndicator){ clickedSortField = SortField.DATE_MODIFIED; }else{ clickedSortField = SortField.PUBLISHED; } changeSortOrder(clickedSortField); } }; nameHeaderLabel.addMouseDownHandler(mouseDownHandler); nameSortIndicator.addMouseDownHandler(mouseDownHandler); dateCreatedHeaderLabel.addMouseDownHandler(mouseDownHandler); dateCreatedSortIndicator.addMouseDownHandler(mouseDownHandler); dateModifiedHeaderLabel.addMouseDownHandler(mouseDownHandler); dateModifiedSortIndicator.addMouseDownHandler(mouseDownHandler); publishedHeaderLabel.addMouseDownHandler(mouseDownHandler); publishedSortIndicator.addMouseDownHandler(mouseDownHandler); }
/** * Adds the header row to the table. * */ private void setHeaderRow() { if (galleryEnabledHolder.enabled) { table.resizeColumns(5); // Number of columns varies based on whether or not // the Gallery is enabled } else { table.resizeColumns(4); } table.getRowFormatter().setStyleName(0, "ode-ProjectHeaderRow"); HorizontalPanel emailHeader = new HorizontalPanel(); final Label emailHeaderLabel = new Label("User Email"); int column = 0; emailHeaderLabel.addStyleName("ode-ProjectHeaderLabel"); emailHeader.add(emailHeaderLabel); emailHeader.add(nameSortIndicator); table.setWidget(0, column, emailHeader); column += 1; HorizontalPanel uidHeader = new HorizontalPanel(); final Label uidHeaderLabel = new Label("UID"); uidHeaderLabel.addStyleName("ode-ProjectHeaderLabel"); uidHeader.add(uidHeaderLabel); table.setWidget(0, column++, uidHeader); HorizontalPanel adminHeader = new HorizontalPanel(); final Label adminHeaderLabel = new Label("isAdmin?"); adminHeaderLabel.addStyleName("ode-ProjectHeaderLabel"); adminHeader.add(adminHeaderLabel); table.setWidget(0, column++, adminHeader); if (galleryEnabledHolder.enabled) { HorizontalPanel moderatorHeader = new HorizontalPanel(); final Label moderatorHeaderLabel = new Label("isModerator?"); moderatorHeaderLabel.addStyleName("ode-ProjectHeaderLabel"); moderatorHeader.add(moderatorHeaderLabel); table.setWidget(0, column++, moderatorHeader); } HorizontalPanel visitedHeader = new HorizontalPanel(); final Label visitedLabel = new Label("Visited"); visitedLabel.addStyleName("ode-ProjectHeaderLabel"); visitedHeader.add(visitedLabel); visitedHeader.add(visitedSortIndicator); table.setWidget(0, column++, visitedHeader); MouseDownHandler mouseDownHandler = new MouseDownHandler() { @Override public void onMouseDown(MouseDownEvent e) { SortField clickedSortField; if (e.getSource() == emailHeaderLabel || e.getSource() == nameSortIndicator) { clickedSortField = SortField.NAME; } else if (e.getSource() == visitedLabel || e.getSource() == visitedSortIndicator) { clickedSortField = SortField.VISITED; } else { return; } changeSortOrder(clickedSortField); } }; emailHeaderLabel.addMouseDownHandler(mouseDownHandler); nameSortIndicator.addMouseDownHandler(mouseDownHandler); visitedLabel.addMouseDownHandler(mouseDownHandler); visitedSortIndicator.addMouseDownHandler(mouseDownHandler); }
public void testDynamicTab() { // given MaterialTab tab = getWidget(); // when / then // This will dynamically add new Tab Item MaterialTabItem item = newTabItem(tab, row, 1); boolean[] selectionEventFired = new boolean[]{false}; tab.addSelectionHandler(selectionEvent -> selectionEventFired[0] = true); // This will trigger the selection event of the tab once tab item fired MouseDownEvent item.fireEvent(new GwtEvent<MouseDownHandler>() { @Override public Type<MouseDownHandler> getAssociatedType() { return MouseDownEvent.getType(); } @Override protected void dispatch(MouseDownHandler eventHandler) { eventHandler.onMouseDown(null); } }); // Expected : true assertTrue(selectionEventFired[0]); }
public static MouseDownHandler createOnMouseDownListener(final EventListenerGVO ev, final List<InputVariableGVO> input) { return new MouseDownHandler() { public void onMouseDown(MouseDownEvent event) { Map<String,String> mouseInfo = getMouseInfo(event); CallbackHandler.createCallBack(event.getSource(), QAMLConstants.EVENT_ONMOUSE_DOWN, ev, input, mouseInfo); } }; }
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) { eventHandlers.put(handler, (DomEvent.Type) MouseDownEvent.getType()); if (canvas != null) { canvas.addDomHandler(handler, MouseDownEvent.getType()); } return null; }
@Test public void checkDOMElementCreationChecksListBoxIsMultipleSelect() { factory.createDomElement(gridLayer, gridWidget, cellRenderContext); verify(listBox).addMouseDownHandler(any(MouseDownHandler.class)); verify(listBox).addKeyDownHandler(any(KeyDownHandler.class)); verify(listBox).addBlurHandler(any(BlurHandler.class)); verify(listBox).isMultipleSelect(); }
@Test public void testAddMouseDownHandlerAttachesToRootPanel() { //Ensure nobody thinks its a good idea to attach to the GridPanel at some time in the future! //See https://issues.jboss.org/browse/GUVNOR-3491 final MouseDownHandler handler = mock(MouseDownHandler.class); view.addMouseDownHandler(handler); verify(mockGridPanel, never()).addMouseDownHandler(eq(handler)); verify(rootPanel).addDomHandler(eq(handler), eq(MouseDownEvent.getType())); }
@Override public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) { return addHandler(handler, MouseDownEvent.getType()); }
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) { return addDomHandler(handler, MouseDownEvent.getType()); }
@Override public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) { return addDomHandler(handler, MouseDownEvent.getType()); }
@Override public HandlerRegistration addMouseDownHandler(final MouseDownHandler handler) { return this.addHandler(handler, MouseDownEvent.getType()); }