Beispiel #1
0
  @IMEventHandler(IMEventType.SHOW_MSG_HISTORY_WINDOW)
  protected void processIMShowWindow(IMEvent event) {
    namedObject = (UINamedObject) event.getTarget();
    setTitle(namedObject.getName() + " - Message History.");

    Window win = event.getData("view");
    Rectangle rect = win.getBounds();
    setLocation(rect.x + rect.width - 50, rect.y);
    setSize(getWidth(), rect.height);
    validate();
    setVisible(true);

    currentPage = 0;
    totalPage = 0;

    // 显示消息
    IMEvent imEvent = new IMEvent(IMEventType.MSG_HISTORY_FIND, namedObject.getEntity());
    imEvent.putData("limit", limit);
    IMEventService events = getContext().getSerivce(IMService.Type.EVENT);
    events.broadcast(imEvent);

    win.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentMoved(ComponentEvent e) {
            int x = e.getComponent().getX() + e.getComponent().getWidth() - 50;
            int y = e.getComponent().getY();
            if (isPtInRect(getBounds(), new Point(x, y))) {
              setLocation(x, y);
              setSize(getWidth(), e.getComponent().getHeight());
            }
          }
        });
  }
  private void reloadMembers() {
    GroupMemberListModel model = (GroupMemberListModel) listModels.get(namedObject.getEntity());

    List<? extends QQStranger> members = getMembers();

    if (model == null) {
      model = new GroupMemberListModel(new UserListComparator());
      for (QQStranger m : members) {
        model.addElement(new UserListElement(new UIUser(m)));

        // 下载头像, 只下载一次,后面是手动更新
        if (isLoadFace) {
          IMEventService events = getContext().getSerivce(IMService.Type.EVENT);
          events.broadcast(new IMEvent(IMEventType.USER_FACE_REQUEST, m));
        }
      }
      listModels.put(namedObject.getEntity(), model);
    }

    model.sort(); // 根据状态排序
    membersCount.setText("Members (" + getOnlineCount(members) + "/" + members.size() + ")");
    if (model != memberList.getModel()) {
      memberList.setModel(model);
    }
    model.updateAll();
    // 停止进度条
    progressOverlay.setShowLoad(false);
  }
  @IMEventHandler(IMEventType.SHOW_MEMBERS_WINDOW)
  protected void showMembersWindow(IMEvent event) {
    UINamedObject named = (UINamedObject) event.getTarget();
    Window win = event.getData("view");
    Rectangle rect = win.getBounds();
    setLocation(rect.x + rect.width - 30, rect.y + 25);

    setIconImage(named.getIcon());
    setTitle(named.getName());
    this.namedObject = named;

    progressOverlay.setShowLoad(true);
    setVisible(true);

    isLoadFace = true; // 设置允许下载头像

    checkReloadMembers(namedObject); // 显示成员

    win.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentMoved(ComponentEvent e) {
            int x = e.getComponent().getX() + e.getComponent().getWidth() - 30;
            int y = e.getComponent().getY() + 25;
            if (isPtInRect(getBounds(), new Point(x, y))) {
              setLocation(x, y);
            }
          }
        });
  }
 /** @param named */
 private void updateMembers(UINamedObject named) {
   IMEventService events = getContext().getSerivce(IMService.Type.EVENT);
   if (named instanceof UIGroup) {
     events.broadcast(new IMEvent(IMEventType.GROUP_INFO_REQUEST, named.getEntity()));
   } else if (named instanceof UIDiscuz) {
     events.broadcast(new IMEvent(IMEventType.DISCUZ_INFO_REQUEST, named.getEntity()));
   } else {
     LOG.info("Unkown UINamedObject type:" + named);
   }
 }
 protected List<? extends QQStranger> getMembers() {
   List<? extends QQStranger> members = null;
   if (namedObject instanceof UIGroup) {
     QQGroup group = (QQGroup) namedObject.getEntity();
     members = group.getMembers();
   } else if (namedObject instanceof UIDiscuz) {
     QQDiscuz discuz = (QQDiscuz) namedObject.getEntity();
     members = discuz.getMembers();
   } else {
     LOG.info("Unkown UINamedObject type:" + namedObject);
   }
   return members;
 }