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

The following are top voted examples for showing how to use com.google.gwt.event.dom.client.MouseDownHandler. 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: 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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 10
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 11
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 12
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 13
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 14
Project: appformer   File: Canvas.java   Source Code and License 6 votes vote down vote up
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
    return html.addMouseDownHandler(handler);
}
 
Example 15
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 16
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 17
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 18
Project: drools-wb   File: GuidedDecisionTableModellerPresenterTest.java   Source Code and License 6 votes vote down vote up
@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());
}
 
Example 19
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 20
Project: appinventor-extensions   File: ProjectList.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
}
 
Example 21
Project: appinventor-extensions   File: AdminUserList.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
}
 
Example 22
Project: gwt-material   File: MaterialTabTest.java   Source Code and License 5 votes vote down vote up
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]);
}
 
Example 23
Project: qafe-platform   File: EventFactory.java   Source Code and License 5 votes vote down vote up
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);
		}
	};
}
 
Example 24
Project: QMAClone   File: PopupCanvas.java   Source Code and License 5 votes vote down vote up
@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;
}
 
Example 25
Project: drools-wb   File: ListBoxSingletonDOMElementFactoryTest.java   Source Code and License 5 votes vote down vote up
@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();
}
 
Example 26
Project: drools-wb   File: GuidedDecisionTableModellerViewImplTest.java   Source Code and License 5 votes vote down vote up
@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()));
}
 
Example 27
Project: unitimes   File: TravelTimes.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return addHandler(handler, MouseDownEvent.getType());
}
 
Example 28
Project: unitimes   File: P.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return addHandler(handler, MouseDownEvent.getType());
}
 
Example 29
Project: unitimes   File: IntervalSelector.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return addHandler(handler, MouseDownEvent.getType());
}
 
Example 30
Project: unitimes   File: SingleDateSelector.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return addHandler(handler, MouseDownEvent.getType());
}
 
Example 31
Project: unitimes   File: SingleDateSelector.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return addHandler(handler, MouseDownEvent.getType());
}
 
Example 32
Project: appinventor-extensions   File: HandlerPanel.java   Source Code and License 4 votes vote down vote up
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
  return addDomHandler(handler, MouseDownEvent.getType());
}
 
Example 33
Project: Wiab.pro   File: ImplPanel.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
  return addDomHandler(handler, MouseDownEvent.getType());
}
 
Example 34
Project: mgwt-traffic-flow   File: Canvas.java   Source Code and License 4 votes vote down vote up
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return html.addMouseDownHandler(handler);
}
 
Example 35
Project: r01fb   File: TreeView.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(final MouseDownHandler handler) {
	return this.addHandler(handler, 
					  	   MouseDownEvent.getType());
}
 
Example 36
Project: unitime   File: TravelTimes.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return addHandler(handler, MouseDownEvent.getType());
}
 
Example 37
Project: unitime   File: P.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return addHandler(handler, MouseDownEvent.getType());
}
 
Example 38
Project: unitime   File: IntervalSelector.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return addHandler(handler, MouseDownEvent.getType());
}
 
Example 39
Project: unitime   File: SingleDateSelector.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return addHandler(handler, MouseDownEvent.getType());
}
 
Example 40
Project: unitime   File: SingleDateSelector.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return addHandler(handler, MouseDownEvent.getType());
}
 
Example 41
Project: appformer   File: TabPanelEntry.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
    return addDomHandler(handler,
                         MouseDownEvent.getType());
}
 
Example 42
Project: appformer   File: DragArea.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
    return addDomHandler(handler,
                         MouseDownEvent.getType());
}
 
Example 43
Project: risk   File: RiskGraphics.java   Source Code and License 4 votes vote down vote up
private List<HandlerRegistration> addTerritoryHandlers(final String territoryId) {
  try {
    List<HandlerRegistration> handlerRegistrations = new ArrayList<HandlerRegistration>();
    final OMElement territory = boardElt.getElementById(territoryId);
    final OMElement territoryText = boardElt.getElementById(territoryId + "_text");
    final OMElement territoryUnits = boardElt.getElementById(territoryId + "_units");
    
    MouseDownHandler handler = new MouseDownHandler() {
      @Override
      public void onMouseDown(MouseDownEvent event) {
        String playerId = riskPresenter.getMyPlayerId();
        if (currentRiskState.getTurn().equals(playerId)) {
          if (claimTerritory) {
            claimTerritory(territoryId);
          } else if (deployment) {
            deployment(territoryId);
          } else if (reinforce) {
            reinforce(territoryId);
          } else if (attack) {
            attack(territoryId);
          } else if (fortify) {
            fortify(territoryId, null);
          }
        } else if (playerId.equals(GameApi.VIEWER_ID)) {
          CustomDialogPanel.alert(constantMessages.notAllowed(), 
              constantMessages.viewerNotAllowed(), null, constantMessages.ok());
        } else {
          CustomDialogPanel.alert(constantMessages.notAllowed(), 
              constantMessages.playerNotAllowed(), null, constantMessages.ok());
        }
      }
    };
    handlerRegistrations.add(((OMNode) territory)
        .addDomHandler(handler, MouseDownEvent.getType()));
    handlerRegistrations.add(((OMNode) territoryText)
        .addDomHandler(handler, MouseDownEvent.getType()));
    handlerRegistrations.add(((OMNode) territoryUnits)
        .addDomHandler(handler, MouseDownEvent.getType()));
    return handlerRegistrations;
  } catch (Exception e) {
    System.out.println(territoryId);
    e.printStackTrace();
  }
  return new ArrayList<HandlerRegistration>();
}
 
Example 44
Project: hexa.tools   File: DataTable.java   Source Code and License 4 votes vote down vote up
public HandlerRegistration addCellMouseDownHandler( final MouseDownHandler handler )
{
	return addDomHandler( handler, MouseDownEvent.getType() );
}
 
Example 45
Project: hexa.tools   File: MiracleTable.java   Source Code and License 4 votes vote down vote up
public HandlerRegistration addMouseDownHandler( MouseDownHandler handler )
{
	sinkEvents( Event.ONMOUSEDOWN );
	return addDomHandler( handler, MouseDownEvent.getType() );
}
 
Example 46
Project: putnami-web-toolkit   File: AbstractInput.java   Source Code and License 4 votes vote down vote up
@Override
public com.google.gwt.event.shared.HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return this.addDomHandler(handler, MouseDownEvent.getType());
}
 
Example 47
Project: putnami-web-toolkit   File: ListItem.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return this.addDomHandler(handler, MouseDownEvent.getType());
}
 
Example 48
Project: putnami-web-toolkit   File: Anchor.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return this.addDomHandler(handler, MouseDownEvent.getType());
}
 
Example 49
Project: gwtoauthlogindemo   File: ButtonCaption.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler)
{
    return addMouseDownHandler(handler);
}
 
Example 50
Project: atom   File: GxtListBoxProxy.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return addDomHandler(handler, MouseDownEvent.getType());
}
 
Example 51
Project: QMAClone   File: MarkedCanvas.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return canvas.addMouseDownHandler(handler);
}
 
Example 52
Project: QMAClone   File: MouseEventsCanvas.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return addDomHandler(handler, MouseDownEvent.getType());
}
 
Example 53
Project: geomajas-project-client-gwt   File: GraphicsWidget.java   Source Code and License 4 votes vote down vote up
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return widget.addMouseDownHandler(handler);
}
 
Example 54
Project: geomajas-project-client-gwt2   File: MapWidgetImpl.java   Source Code and License 4 votes vote down vote up
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
	return addDomHandler(handler, MouseDownEvent.getType());
}
 
Example 55
Project: gwtbootstrap3   File: AbstractButton.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(final MouseDownHandler handler) {
    return addDomHandler(handler, MouseDownEvent.getType());
}
 
Example 56
Project: gwtbootstrap3   File: Label.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(final MouseDownHandler handler) {
    return addDomHandler(handler, MouseDownEvent.getType());
}
 
Example 57
Project: incubator-wave   File: ClickableDivPanel.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
  return addDomHandler(handler, MouseDownEvent.getType());
}
 
Example 58
Project: incubator-wave   File: ImplPanel.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) {
  return addDomHandler(handler, MouseDownEvent.getType());
}
 
Example 59
Project: drools-wb   File: GuidedDecisionTableModellerContextMenuSupport.java   Source Code and License 4 votes vote down vote up
public MouseDownHandler getContextMenuMouseDownHandler() {
    return new GuidedDecisionTableModellerContextMenuMouseDownHandler(cellContextMenu,
                                                                      rowContextMenu);
}
 
Example 60
Project: drools-wb   File: GuidedDecisionTableModellerViewImpl.java   Source Code and License 4 votes vote down vote up
@Override
public HandlerRegistration addMouseDownHandler(final MouseDownHandler handler) {
    return rootPanel().addDomHandler(handler,
                                     MouseDownEvent.getType());
}