Java Code Examples for com.google.gwt.user.client.ui.Label#addMouseDownHandler()

The following examples show how to use com.google.gwt.user.client.ui.Label#addMouseDownHandler() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Leaf.java    From EasyML with Apache License 2.0 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 2
Source File: SimpleDayCell.java    From calendar-component with Apache License 2.0 6 votes vote down vote up
public SimpleDayCell(VCalendar calendar, int row, int cell) {
    this.calendar = calendar;
    this.row = row;
    this.cell = cell;
    setStylePrimaryName("v-calendar-month-day");
    caption = new Label();
    caption.setStyleName("v-calendar-day-number");
    caption.addMouseDownHandler(this);
    caption.addMouseUpHandler(this);
    add(caption);

    bottomspacer = new HTML();
    bottomspacer.setStyleName("v-calendar-bottom-spacer-empty");
    bottomspacer.setWidth(3 + "em");
    add(bottomspacer);
}
 
Example 3
Source File: IconButtonTemplate.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@UiConstructor
public IconButtonTemplate() {
  Label label = new Label();
  initWidget(label);
  label.addClickHandler(this);
  label.addMouseOverHandler(this);
  label.addMouseOutHandler(this);
  label.addMouseUpHandler(this);
  label.addMouseDownHandler(this);
}
 
Example 4
Source File: IconButtonTemplate.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@UiConstructor
public IconButtonTemplate() {
  Label label = new Label();
  initWidget(label);
  label.addClickHandler(this);
  label.addMouseOverHandler(this);
  label.addMouseOutHandler(this);
  label.addMouseUpHandler(this);
  label.addMouseDownHandler(this);
}
 
Example 5
Source File: ProjectList.java    From appinventor-extensions with Apache License 2.0 4 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 6
Source File: TrashProjectList.java    From appinventor-extensions with Apache License 2.0 4 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 7
Source File: AdminUserList.java    From appinventor-extensions with Apache License 2.0 4 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);
}