Exemplo n.º 1
0
    @Override
    public void valueChanged(ListSelectionEvent e) {

      if (!e.getValueIsAdjusting()) {
        int rowNum = table.getSelectedRow();
        if (rowNum >= 0) {
          // get table model
          PeptideSpeciesPSMTableModel pepTableModel =
              (PeptideSpeciesPSMTableModel) table.getModel();

          // get spectrum reference column
          int identColNum =
              pepTableModel.getColumnIndex(PeptideTableHeader.IDENTIFICATION_ID.getHeader());
          int peptideColNum =
              pepTableModel.getColumnIndex(PeptideTableHeader.PEPTIDE_ID.getHeader());

          // get spectrum id
          int modelRowIndex = table.convertRowIndexToModel(rowNum);
          Comparable identId = (Comparable) pepTableModel.getValueAt(modelRowIndex, identColNum);
          Comparable peptideId =
              (Comparable) pepTableModel.getValueAt(modelRowIndex, peptideColNum);

          logger.debug(
              "Peptide table selection:  Protein id: " + identId + " Peptide Id: " + peptideId);

          // fire a background task to retrieve peptide
          if (peptideId != null && identId != null) {
            // publish the event to local event bus
            EventService eventBus =
                ContainerEventServiceFinder.getEventService(PeptidePSMPane.this);
            eventBus.publish(new PSMEvent(PeptidePSMPane.this, controller, identId, peptideId));
          }
        }
      }
    }
  private static void process(EventTopicSubscriber topicAnnotation, Object obj, Method method) {
    // Check args
    String topic = topicAnnotation.topic();
    if (topic == null) {
      throw new IllegalArgumentException(
          "Topic cannot be null for EventTopicSubscriber annotation");
    }

    // Get event service
    Class<? extends EventService> eventServiceClass = topicAnnotation.autoCreateEventServiceClass();
    String eventServiceName = topicAnnotation.eventServiceName();
    EventService eventService = getEventServiceFromAnnotation(eventServiceName, eventServiceClass);

    // Create proxy and subscribe
    ProxyTopicSubscriber subscriber =
        new ProxyTopicSubscriber(
            obj, method, topicAnnotation.referenceStrength(), eventService, topic);

    // See Issue #18
    // Also note that this post is wrong:
    // https://eventbus.dev.java.net/servlets/ProjectForumMessageView?messageID=19499&forumID=1834
    // Since two WeakReferences are not treated as one.  So this always has to be strong and we'll
    // have to clean up occasionally.
    eventService.subscribeStrongly(topic, subscriber);
  }
Exemplo n.º 3
0
  @Override
  public void subscribeToEventBus(EventService eventBus) {
    if (eventBus == null) {
      eventBus = ContainerEventServiceFinder.getEventService(this);
    }
    peptideSpeciesEventSubscriber = new PeptideSpeciesEventSubscriber(psmTable);
    eventBus.subscribe(PeptideSpeciesEvent.class, peptideSpeciesEventSubscriber);

    changeRankingThresholdEventSubscriber = new ChangeRankingThresholdEventSubscriber(psmTable);
    eventBus.subscribe(ChangeRankingThresholdEvent.class, changeRankingThresholdEventSubscriber);
  }
  private static void process(EventSubscriber annotation, Object obj, Method method) {
    // Check args
    Class eventClass = annotation.eventClass();
    if (eventClass == null) {
      throw new IllegalArgumentException(
          "Event class cannot be null for EventSubscriber annotation");
    } else if (UseTheClassOfTheAnnotatedMethodsParameter.class.equals(eventClass)) {
      Class[] params = method.getParameterTypes();
      if (params.length < 1) {
        throw new RuntimeException("Expected annotated method to have one parameter.");
      } else {
        eventClass = params[0];
      }
    }

    // Get event service
    Class<? extends EventService> eventServiceClass = annotation.autoCreateEventServiceClass();
    String eventServiceName = annotation.eventServiceName();
    EventService eventService = getEventServiceFromAnnotation(eventServiceName, eventServiceClass);

    // Create proxy and subscribe
    // See
    // https://eventbus.dev.java.net/servlets/ProjectForumMessageView?messageID=19499&forumID=1834
    BaseProxySubscriber subscriber =
        new BaseProxySubscriber(
            obj, method, annotation.referenceStrength(), eventService, eventClass);
    if (annotation.exact()) {
      // See Issue #18
      // Also note that this post is wrong:
      // https://eventbus.dev.java.net/servlets/ProjectForumMessageView?messageID=19499&forumID=1834
      // Since two WeakReferences are not treated as one.  So this always has to be strong and we'll
      // have to clean up occasionally.
      eventService.subscribeExactlyStrongly(eventClass, subscriber);
    } else {
      // See Issue #18
      // Also note that this post is wrong:
      // https://eventbus.dev.java.net/servlets/ProjectForumMessageView?messageID=19499&forumID=1834
      // Since two WeakReferences are not treated as one.  So this always has to be strong and we'll
      // have to clean up occasionally.
      eventService.subscribeStrongly(eventClass, subscriber);
    }
  }