Ejemplo n.º 1
0
  /*
   * Implements PopupMenuListener#popupMenuWillBecomeVisible(PopupMenuEvent).
   */
  public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    createOtrContactMenus(currentContact);

    JMenu menu = getMenu();

    menu.addSeparator();

    whatsThis = new JMenuItem();
    whatsThis.setIcon(OtrActivator.resourceService.getImage("plugin.otr.HELP_ICON_15x15"));
    whatsThis.setText(OtrActivator.resourceService.getI18NString("plugin.otr.menu.WHATS_THIS"));
    whatsThis.addActionListener(this);
    menu.add(whatsThis);
  }
Ejemplo n.º 2
0
  /**
   * Gets the <tt>JMenu</tt> which is the component of this plug-in. If it still doesn't exist, it's
   * created.
   *
   * @return the <tt>JMenu</tt> which is the component of this plug-in
   */
  private JMenu getMenu() {
    if (menu == null) {
      menu = new SIPCommMenu();
      menu.setText(getName());

      if (Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU.equals(getContainer())) {
        Icon icon = OtrActivator.resourceService.getImage("plugin.otr.MENU_ITEM_ICON_16x16");

        if (icon != null) menu.setIcon(icon);
      }

      if (!inMacOSXScreenMenuBar) menu.getPopupMenu().addPopupMenuListener(this);
    }
    return menu;
  }
Ejemplo n.º 3
0
  /**
   * Creates an {@link OtrContactMenu} for each {@link Contact} contained in the
   * <tt>metaContact</tt>.
   *
   * @param metaContact The {@link MetaContact} this {@link OtrMetaContactMenu} refers to.
   */
  private void createOtrContactMenus(MetaContact metaContact) {
    JMenu menu = getMenu();

    // Remove any existing OtrContactMenu items.
    menu.removeAll();

    // Create the new OtrContactMenu items.
    if (metaContact != null) {
      Iterator<Contact> contacts = metaContact.getContacts();

      if (metaContact.getContactCount() == 1) {
        new OtrContactMenu(contacts.next(), inMacOSXScreenMenuBar, menu, false);
      } else
        while (contacts.hasNext()) {
          new OtrContactMenu(contacts.next(), inMacOSXScreenMenuBar, menu, true);
        }
    }
  }
Ejemplo n.º 4
0
  /*
   * Implements PluginComponent#setCurrentContact(MetaContact).
   */
  @Override
  public void setCurrentContact(MetaContact metaContact) {
    if (this.currentContact != metaContact) {
      this.currentContact = metaContact;

      if (inMacOSXScreenMenuBar) popupMenuWillBecomeVisible(null);
      else if ((menu != null) && menu.isPopupMenuVisible()) createOtrContactMenus(currentContact);
    }
  }