示例#1
0
 @Override
 public void onPointerEnd(float x, float y) {
   pressed = false;
   if (pointInButton(x, y) && clickHandler != null) {
     ClickEvent click = new ClickEvent();
     click.sender = this;
     clickHandler.onClick(click);
   }
 }
示例#2
0
  public static EventMessage create(Map<String, Object> map) throws Exception {
    EventMessage message = null;
    String event = map.get("Event").toString();

    if (event.equals("LOCATION")) {
      LocationEvent locationEvent = new LocationEvent();
      locationEvent.setLatitude(Double.parseDouble(map.get("Latitude").toString()));
      locationEvent.setLongitude(Double.parseDouble(map.get("Longitude").toString()));
      locationEvent.setPrecision(Float.parseFloat(map.get("Precision").toString()));
      message = locationEvent;
    } else if (event.equals("subscribe")) {
      SubscribeEvent subscribeEvent = new SubscribeEvent();
      message = subscribeEvent;
    } else if (event.equals("CLICK")) {
      ClickEvent mentEvent = new ClickEvent();
      mentEvent.setEventKey(map.get("EventKey").toString());
      message = mentEvent;
    } else if (event.equals("scancode_waitmsg")) {
      ScancodeWaitEvent scancodeWaitEvent = new ScancodeWaitEvent();
      scancodeWaitEvent.setEventKey(map.get("EventKey").toString());
      Map<String, Object> scanCodeInfoMap = (Map<String, Object>) map.get("ScanCodeInfo");
      ScanCodeInfo scanCodeInfo = new ScanCodeInfo();
      scanCodeInfo.setScanType(scanCodeInfoMap.get("ScanType").toString());
      scanCodeInfo.setScanResult(scanCodeInfoMap.get("ScanResult").toString());
      scancodeWaitEvent.setScanCodeInfo(scanCodeInfo);
      message = scancodeWaitEvent;
    } else if (event.equals("unsubscribe")) {
      UnSubscribeEvent unsubscribeEvent = new UnSubscribeEvent();
      message = unsubscribeEvent;
    } else if (event.equals("VIEW")) {
      ViewEvent mentEvent = new ViewEvent();
      mentEvent.setEventKey(map.get("EventKey").toString());
      message = mentEvent;
    } else if (event.equals("SCAN")) {
      QrEvent qrEvent = new QrEvent();
      qrEvent.setEventKey(map.get("EventKey").toString());
      qrEvent.setTicket(map.get("Ticket").toString());
      message = qrEvent;
    } else {
      throw new Exception("Unsupported message.");
    }

    message.setEvent(event);
    message.setToUserName(map.get("ToUserName").toString());
    message.setFromUserName(map.get("FromUserName").toString());
    message.setCreateTime(Long.parseLong(map.get("CreateTime").toString()));
    message.setMsgType(MessageType.create(map.get("MsgType").toString()));
    return message;
  }
示例#3
0
    public void onClick(ClickEvent event) {
      // If clicking on the input panel already, stop propagation.
      if (event.getSource() == input_) {
        event.stopPropagation();
        return;
      }

      // Don't drive focus to the input unless there is no selection.
      // Otherwise it would interfere with the ability to select stuff
      // from the output buffer for copying to the clipboard.
      // (BUG: DomUtils.selectionExists() doesn't work in a timely
      // fashion on IE8.)
      if (!DomUtils.selectionExists() && isInputOnscreen()) {
        input_.setFocus(true);
        DomUtils.collapseSelection(false);
      }
    }
示例#4
0
  @Override
  public HandlerRegistration addClickHandler(ClickHandler clickHandler) {
    /*
     * When we directly subscribe to this widget's ClickEvent, sometimes the
     * click gets ignored (inconsistent repro but it happens enough to be
     * annoying). Doing it this way fixes it.
     */

    hasHandlers_.addHandler(ClickEvent.getType(), clickHandler);

    final HandlerRegistration mouseDown =
        addMouseDownHandler(
            new MouseDownHandler() {
              public void onMouseDown(MouseDownEvent event) {
                event.preventDefault();
                event.stopPropagation();

                addStyleName(styles_.toolbarButtonPushed());
                down_ = true;
              }
            });

    final HandlerRegistration mouseOut =
        addMouseOutHandler(
            new MouseOutHandler() {
              public void onMouseOut(MouseOutEvent event) {
                event.preventDefault();
                event.stopPropagation();

                removeStyleName(styles_.toolbarButtonPushed());
                down_ = false;
              }
            });

    final HandlerRegistration mouseUp =
        addMouseUpHandler(
            new MouseUpHandler() {
              public void onMouseUp(MouseUpEvent event) {
                event.preventDefault();
                event.stopPropagation();

                if (down_) {
                  down_ = false;
                  removeStyleName(styles_.toolbarButtonPushed());

                  NativeEvent clickEvent =
                      Document.get()
                          .createClickEvent(
                              1,
                              event.getScreenX(),
                              event.getScreenY(),
                              event.getClientX(),
                              event.getClientY(),
                              event.getNativeEvent().getCtrlKey(),
                              event.getNativeEvent().getAltKey(),
                              event.getNativeEvent().getShiftKey(),
                              event.getNativeEvent().getMetaKey());
                  DomEvent.fireNativeEvent(clickEvent, hasHandlers_);
                }
              }
            });

    return new HandlerRegistration() {
      public void removeHandler() {
        mouseDown.removeHandler();
        mouseOut.removeHandler();
        mouseUp.removeHandler();
      }
    };
  }
示例#5
0
  @UiHandler("getHyperlink")
  void getHyperlink(ClickEvent event) {
    MultiSelectionModel<SessionDataDto> sessionModel =
        (MultiSelectionModel) sessionsDataGrid.getSelectionModel();
    MultiSelectionModel<TaskDataDto> testModel =
        (MultiSelectionModel) testDataGrid.getSelectionModel();

    Set<SessionDataDto> sessions = sessionModel.getSelectedSet();

    Set<TaskDataDto> tests = testModel.getSelectedSet();

    Set<MetricNameDto> metrics = metricPanel.getSelected();

    TaskDataTreeViewModel taskDataTreeViewModel =
        (TaskDataTreeViewModel) taskDetailsTree.getTreeViewModel();
    Set<PlotNameDto> trends = taskDataTreeViewModel.getSelectionModel().getSelectedSet();

    HashSet<String> sessionsIds = new HashSet<String>();
    HashSet<TestsMetrics> testsMetricses = new HashSet<TestsMetrics>(tests.size());
    HashMap<String, TestsMetrics> map = new HashMap<String, TestsMetrics>(tests.size());

    for (SessionDataDto session : sessions) {
      sessionsIds.add(session.getSessionId());
    }

    for (TaskDataDto taskDataDto : tests) {
      TestsMetrics testsMetrics =
          new TestsMetrics(taskDataDto.getTaskName(), new HashSet<String>(), new HashSet<String>());
      testsMetricses.add(testsMetrics);
      map.put(taskDataDto.getTaskName(), testsMetrics);
    }

    for (MetricNameDto metricNameDto : metrics) {
      map.get(metricNameDto.getTests().getTaskName()).getMetrics().add(metricNameDto.getName());
    }

    for (PlotNameDto plotNameDto : trends) {
      map.get(plotNameDto.getTest().getTaskName()).getTrends().add(plotNameDto.getPlotName());
    }

    TrendsPlace newPlace =
        new TrendsPlace(
            mainTabPanel.getSelectedIndex() == 0
                ? NameTokens.SUMMARY
                : mainTabPanel.getSelectedIndex() == 1 ? NameTokens.TRENDS : NameTokens.METRICS);

    newPlace.setSelectedSessionIds(sessionsIds);
    newPlace.setSelectedTestsMetrics(testsMetricses);
    newPlace.setSessionTrends(sessionPlotPanel.getSelected());

    String linkText =
        Window.Location.getHost()
            + Window.Location.getPath()
            + Window.Location.getQueryString()
            + "#"
            + new JaggerPlaceHistoryMapper().getToken(newPlace);
    linkText = URL.encode(linkText);

    // create a dialog for copy link
    final DialogBox dialog = new DialogBox(false, true);
    dialog.setText("Share link");
    dialog.setModal(true);
    dialog.setAutoHideEnabled(true);
    dialog.setPopupPosition(event.getClientX(), event.getClientY());

    final TextArea textArea = new TextArea();
    textArea.setText(linkText);
    textArea.setWidth("300px");
    textArea.setHeight("40px");
    // select text
    Scheduler.get()
        .scheduleDeferred(
            new Scheduler.ScheduledCommand() {
              @Override
              public void execute() {
                textArea.setVisible(true);
                textArea.setFocus(true);
                textArea.selectAll();
              }
            });

    dialog.add(textArea);

    dialog.show();
  }
示例#6
0
 public HandlerRegistration addClickHandler(ClickHandler handler) {
   return addDomHandler(handler, ClickEvent.getType());
 }
示例#7
0
 @Override
 public HandlerRegistration addClickHandler(final ClickHandler handler) {
   return handlers.addHandler(ClickEvent.getType(), handler);
 }