예제 #1
0
  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);
  }
예제 #2
0
 private void openSelectedHint() {
   if (classSearchHintsList.getSelectedIndex() != -1) {
     final JarEntry entry = (JarEntry) classSearchHintsList.getSelectedValue();
     hideClassSearchPopup();
     viewEntry(entry);
   }
 }
예제 #3
0
  /** 初始化窗口显示 */
  private void initView() {
    setSize(240, 500);
    // setAlwaysOnTop(true);

    IMTitleComponent title = getIMTitleComponent();
    title.setShowMinimizeButton(false);
    title.setShowMaximizeButton(false);

    memberList = new WebList();
    memberList.setCellRenderer(new GroupMemberListCellRenderer());
    WebScrollPane listScroll =
        new WebScrollPane(memberList) {

          {
            setHorizontalScrollBarPolicy(WebScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
            setBorder(null);
            setMargin(0);
            setShadeWidth(0);
            setRound(0);
            setDrawBorder(false);
          }
        };

    content = new WebPanel();
    content.add(listScroll, BorderLayout.CENTER);
    WebPanel rootContent = new WebPanel();
    rootContent.add(title, BorderLayout.PAGE_START);
    rootContent.add(content, BorderLayout.CENTER);
    setContentPanel(rootContent);
  }
예제 #4
0
 /*
  * 有点效率问题,下载头像时更新太频繁
  */
 @IMEventHandler(IMEventType.USER_FACE_UPDATE)
 protected void processIMUpdateUserFace(IMEvent event) {
   ListModel m = memberList.getModel();
   QQUser user = (QQUser) event.getTarget();
   if (m instanceof GroupMemberListModel && user instanceof QQStranger) {
     GroupMemberListModel model = (GroupMemberListModel) m;
     model.update(user);
   }
 }
예제 #5
0
  @Override
  public void mouseClicked(MouseEvent e) {

    if (e.getModifiers() == InputEvent.BUTTON3_MASK) {
      if (!(e.getSource() instanceof WebList)) {
        return;
      }

      list = (WebList) e.getSource();

      if (list.getModel().getSize() <= 0) {
        return;
      }

      int index = list.locationToIndex(e.getPoint());
      if (index >= 0) {
        list.setSelectedIndex(index);
        iimage = (IImage) list.getSelectedValue();
        menu.show(e.getComponent(), e.getX(), e.getY());
      }
    }
  }
예제 #6
0
 public void checkSendSessionMsg() {
   UserListElement userElt = (UserListElement) memberList.getSelectedValue();
   checkSendSessionMsg((QQStranger) userElt.getUserNamed().getUser());
 }
예제 #7
0
  /** 初始化List事件等等动作 */
  private void initMemberList() {
    final WebPopupMenu memberPopup = new WebPopupMenu();
    WebMenuItem openChatItem = new WebMenuItem("发送消息");
    WebMenuItem userDetailsItem = new WebMenuItem("查看资料");
    WebMenuItem refreshListItem = new WebMenuItem("刷新列表");
    WebMenuItem refreshFaceItem = new WebMenuItem("刷新头像");
    memberPopup.add(openChatItem);
    memberPopup.addSeparator();
    memberPopup.add(userDetailsItem);
    memberPopup.addSeparator();
    memberPopup.add(refreshListItem);
    memberPopup.addSeparator();
    memberPopup.add(refreshFaceItem);
    memberPopup.addSeparator();

    memberList.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
              checkSendSessionMsg();
            } else if (e.isMetaDown()) {
              memberPopup.show(e.getComponent(), e.getX(), e.getY());
            }
          }
        });
    openChatItem.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            checkSendSessionMsg();
          }
        });
    userDetailsItem.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            WebOptionPane.showMessageDialog(UIGroupMemberModule.this, "No Implements!!!");
          }
        });
    refreshListItem.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (namedObject != null) {
              updateMembers(namedObject);
            }
          }
        });
    refreshFaceItem.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (namedObject != null) {
              updateFaces(namedObject);
            }
          }
        });
  }
예제 #8
0
  private void updateHints() {
    String text = classSearchField.getText().trim();

    // Ignore empty text
    if (text.trim().length() == 0) {
      hideHints();
      return;
    }

    // Updating hints window if needed
    if (!CompareUtils.equals(lastSearchedText, text)) {
      // Saving old selection
      Object oldSelection = classSearchHintsList.getSelectedValue();

      // Clearing list
      DefaultListModel model = (DefaultListModel) classSearchHintsList.getModel();
      model.clear();

      // Look for classes
      List<JarEntry> found =
          jarStructure.findSimilarEntries(
              text,
              new Filter<JarEntry>() {
                @Override
                public boolean accept(JarEntry object) {
                  return object.getType().equals(JarEntryType.javaEntry);
                }
              });
      if (found.size() > 0) {
        classSearchField.setForeground(Color.BLACK);

        // Filling list with results
        for (JarEntry entry : found) {
          model.addElement(entry);
        }

        // Updating visible rows
        classSearchHintsList.setVisibleRowCount(Math.min(model.size(), 10));

        // Restoring selection if possible
        int index = oldSelection != null ? model.indexOf(oldSelection) : 0;
        classSearchHintsList.setSelectedIndex(index != -1 ? index : 0);

        // Packing popup
        classSearchHintsPopup.pack();

        // Displaying hints window
        if (!classSearchHintsPopup.isVisible()) {
          classSearchHintsPopup.setVisible(true);
        }
      } else {
        classSearchField.setForeground(Color.RED);

        // Hiding hints window
        if (classSearchHintsPopup.isVisible()) {
          classSearchHintsPopup.setVisible(false);
        }
      }

      lastSearchedText = text;
    }
  }
예제 #9
0
  private WebButton createClassSearch() {
    WebButton classSearch = new WebButton(classSearchIcon);
    classSearch.setDrawFocus(false);
    classSearch.setRolloverDecoratedOnly(true);
    classSearch.addHotkey(Hotkey.CTRL_N);
    classSearch.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            showClassSearchPopup();
          }
        });

    classSearchField = new WebTextField(20, false);
    classSearchField.setHideInputPromptOnFocus(false);
    classSearchField.setInputPrompt("Enter class name here...");
    HotkeyManager.registerHotkey(
        classSearchField,
        Hotkey.ESCAPE,
        new HotkeyRunnable() {
          @Override
          public void run(KeyEvent e) {
            hideClassSearchPopup();
          }
        });

    final WebImage leadingComponent = new WebImage(classSearchIcon);
    leadingComponent.setMargin(2);
    classSearchField.setLeadingComponent(leadingComponent);

    classSearchPopup = new WebPopup();
    classSearchPopup.setCloseOnFocusLoss(true);
    classSearchPopup.add(classSearchField);
    classSearchPopup.setDefaultFocusComponent(classSearchField);

    classSearchHintsPopup =
        new WebWindow(classSearchPopup) {
          @Override
          public Dimension getPreferredSize() {
            final Dimension ps = super.getPreferredSize();
            ps.width = Math.max(classSearchField.getWidth(), ps.width);
            return ps;
          }
        };
    classSearchHintsPopup.setFocusable(false);
    classSearchHintsPopup.setAlwaysOnTop(true);
    classSearchPopup.addFocusableChild(classSearchHintsPopup);

    classSearchHintsList = new WebList(new DefaultListModel());
    classSearchHintsList.setFocusable(false);
    classSearchHintsList.setRolloverSelectionEnabled(true);
    classSearchHintsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    classSearchHintsList.setCellRenderer(
        new WebListCellRenderer() {
          @Override
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            JarEntry entry = (JarEntry) value;
            WebListElement renderer =
                (WebListElement)
                    super.getListCellRendererComponent(
                        list, value, index, isSelected, cellHasFocus);
            renderer.setIcon(entry.getIcon());
            renderer.setText(entry.getName());
            return renderer;
          }
        });
    classSearchHintsList.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mousePressed(MouseEvent e) {
            if (SwingUtils.isLeftMouseButton(e)) {
              openSelectedHint();
            }
          }
        });

    HotkeyManager.registerHotkey(
        classSearchField,
        Hotkey.HOME,
        new HotkeyRunnable() {
          @Override
          public void run(KeyEvent e) {
            if (classSearchHintsList.getModelSize() > 0) {
              classSearchHintsList.setSelectedIndex(0);
            }
          }
        });
    HotkeyManager.registerHotkey(
        classSearchField,
        Hotkey.UP,
        new HotkeyRunnable() {
          @Override
          public void run(KeyEvent e) {
            if (classSearchHintsList.getModelSize() > 0) {
              int index = classSearchHintsList.getSelectedIndex();
              if (index > 0) {
                classSearchHintsList.setSelectedIndex(index - 1);
              } else {
                classSearchHintsList.setSelectedIndex(classSearchHintsList.getModelSize() - 1);
              }
            }
          }
        });
    HotkeyManager.registerHotkey(
        classSearchField,
        Hotkey.DOWN,
        new HotkeyRunnable() {
          @Override
          public void run(KeyEvent e) {
            if (classSearchHintsList.getModelSize() > 0) {
              int index = classSearchHintsList.getSelectedIndex();
              if (index < classSearchHintsList.getModelSize() - 1) {
                classSearchHintsList.setSelectedIndex(index + 1);
              } else {
                classSearchHintsList.setSelectedIndex(0);
              }
            }
          }
        });
    HotkeyManager.registerHotkey(
        classSearchField,
        Hotkey.END,
        new HotkeyRunnable() {
          @Override
          public void run(KeyEvent e) {
            if (classSearchHintsList.getModelSize() > 0) {
              classSearchHintsList.setSelectedIndex(classSearchHintsList.getModelSize() - 1);
            }
          }
        });
    HotkeyManager.registerHotkey(
        classSearchField,
        Hotkey.ENTER,
        new HotkeyRunnable() {
          @Override
          public void run(KeyEvent e) {
            openSelectedHint();
          }
        });

    WebScrollPane foundClassesScroll = new WebScrollPane(classSearchHintsList);
    foundClassesScroll.setShadeWidth(0);
    foundClassesScroll.setRound(0);
    classSearchHintsPopup.add(foundClassesScroll);

    classSearchPopup.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentMoved(ComponentEvent e) {
            updateHintsLocation();
          }

          @Override
          public void componentResized(ComponentEvent e) {
            updateHintsLocation();
          }
        });

    classSearchPopup.addPopupListener(
        new PopupAdapter() {
          @Override
          public void popupWillBeOpened() {
            lastSearchedText = null;
            lastFocusBeforeSearch = FocusManager.getFocusOwner();
          }

          @Override
          public void popupOpened() {
            updateHints();
          }

          @Override
          public void popupClosed() {
            hideHints();
            if (lastFocusBeforeSearch != null) {
              lastFocusBeforeSearch.requestFocusInWindow();
            }
          }
        });

    classSearchField.addCaretListener(
        new CaretListener() {
          @Override
          public void caretUpdate(CaretEvent e) {
            if (classSearchHintsDelay == null) {
              classSearchHintsDelay =
                  new WebTimer(
                      500,
                      new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                          updateHints();
                        }
                      });
              classSearchHintsDelay.setRepeats(false);
            }
            if (classSearchField.getText().trim().length() > 0) {
              classSearchHintsDelay.restart();
            } else {
              classSearchHintsDelay.stop();
              hideHints();
            }
          }
        });

    return classSearch;
  }
예제 #10
0
    StatusDialog() {
      this.setTitle(Tr.tr("Status"));
      this.setResizable(false);
      this.setModal(true);

      GroupPanel groupPanel = new GroupPanel(10, false);
      groupPanel.setMargin(5);

      String[] strings = mConf.getStringArray(Config.NET_STATUS_LIST);
      List<String> stats = new ArrayList<>(Arrays.<String>asList(strings));
      String currentStatus = "";
      if (!stats.isEmpty()) currentStatus = stats.remove(0);

      stats.remove("");

      groupPanel.add(new WebLabel(Tr.tr("Your current status:")));
      mStatusField = new WebTextField(currentStatus, 30);
      groupPanel.add(mStatusField);
      groupPanel.add(new WebSeparator(true, true));

      groupPanel.add(new WebLabel(Tr.tr("Previously used:")));
      mStatusList = new WebList(stats);
      mStatusList.setMultiplySelectionAllowed(false);
      mStatusList.addListSelectionListener(
          new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
              if (e.getValueIsAdjusting()) return;
              mStatusField.setText(mStatusList.getSelectedValue().toString());
            }
          });
      WebScrollPane listScrollPane = new ScrollPane(mStatusList);
      groupPanel.add(listScrollPane);
      this.add(groupPanel, BorderLayout.CENTER);

      // buttons
      WebButton cancelButton = new WebButton(Tr.tr("Cancel"));
      cancelButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              StatusDialog.this.dispose();
            }
          });
      final WebButton saveButton = new WebButton(Tr.tr("Save"));
      saveButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              StatusDialog.this.saveStatus();
              StatusDialog.this.dispose();
            }
          });
      this.getRootPane().setDefaultButton(saveButton);

      GroupPanel buttonPanel = new GroupPanel(2, cancelButton, saveButton);
      buttonPanel.setLayout(new FlowLayout(FlowLayout.TRAILING));
      this.add(buttonPanel, BorderLayout.SOUTH);

      this.pack();
    }