示例#1
0
 /** Adds separator into menu. */
 public void addSeparator() {
   final E menuComponent = getMenu();
   if (menuComponent instanceof WebMenu) {
     ((WebMenu) menuComponent).addSeparator();
   } else if (menuComponent instanceof WebPopupMenu) {
     ((WebPopupMenu) menuComponent).addSeparator();
   }
 }
  public ContextMenuImage() {

    add =
        new AbstractAction(UIUtils.i18n.getLanguage("rmenu.add", false), ImageUtils.PLUS_16) {
          private static final long serialVersionUID = 1L;

          @Override
          public void actionPerformed(ActionEvent ae) {
            // list.remove(index);
          }
        };

    edit =
        new AbstractAction(UIUtils.i18n.getLanguage("rmenu.edit", false), ImageUtils.EDIT_16) {
          private static final long serialVersionUID = 1L;

          @Override
          public void actionPerformed(ActionEvent ae) {
            // list.remove(index);
          }
        };

    delete =
        new AbstractAction(UIUtils.i18n.getLanguage("rmenu.delete", false), ImageUtils.DELETE_16) {
          private static final long serialVersionUID = 1L;

          @Override
          @SuppressWarnings("unchecked")
          public void actionPerformed(ActionEvent ae) {
            ImageListModel<IImage> model = (ImageListModel<IImage>) list.getModel();
            model.removeElement(iimage);
          }
        };

    menu.add(add);
    menu.add(edit);
    menu.addSeparator();
    menu.add(delete);
  }
  @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());
      }
    }
  }
  /** 初始化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);
            }
          }
        });
  }