Пример #1
0
  private void showSliderMenu() {
    Point location = new Point(getX(), getY() + getHeight());

    SwingUtilities.convertPointToScreen(location, InputVolumeControlButton.this.getParent());

    if (isFullScreen()) {
      location.setLocation(
          location.getX(),
          location.getY() - sliderMenu.getPreferredSize().getHeight() - getHeight());
    }

    sliderMenu.setLocation(location);

    sliderMenu.addPopupMenuListener(
        new PopupMenuListener() {
          public void popupMenuWillBecomeVisible(PopupMenuEvent ev) {
            sliderMenuIsVisible = true;
          }

          public void popupMenuWillBecomeInvisible(PopupMenuEvent ev) {
            sliderMenuIsVisible = false;
          }

          public void popupMenuCanceled(PopupMenuEvent ev) {}
        });

    sliderMenu.setVisible(!sliderMenu.isVisible());
  }
Пример #2
0
  /**
   * A chat room was selected. Opens the chat room in the chat window.
   *
   * @param e the <tt>MouseEvent</tt> instance containing details of the event that has just
   *     occurred.
   */
  public void mousePressed(MouseEvent e) {
    // Select the object under the right button click.
    if ((e.getModifiers() & InputEvent.BUTTON2_MASK) != 0
        || (e.getModifiers() & InputEvent.BUTTON3_MASK) != 0
        || (e.isControlDown() && !e.isMetaDown())) {
      int ix = this.chatRoomList.rowAtPoint(e.getPoint());

      if (ix != -1) {
        this.chatRoomList.setRowSelectionInterval(ix, ix);
      }
    }

    Object o = this.chatRoomsTableModel.getValueAt(this.chatRoomList.getSelectedRow());

    Point selectedCellPoint = e.getPoint();

    SwingUtilities.convertPointToScreen(selectedCellPoint, chatRoomList);

    if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
      JPopupMenu rightButtonMenu;

      if (o instanceof ChatRoomWrapper)
        rightButtonMenu = new ChatRoomRightButtonMenu((ChatRoomWrapper) o);
      else return;

      rightButtonMenu.setInvoker(this);
      rightButtonMenu.setLocation(selectedCellPoint);
      rightButtonMenu.setVisible(true);
    }
  }
Пример #3
0
  /**
   * Initializes a new <tt>MuteButton</tt> instance which is to mute the audio stream to a specific
   * <tt>Call</tt>.
   *
   * @param call the <tt>Call</tt> to be associated with the new instance and whose audio stream is
   *     to be muted upon performing its action
   * @param iconImageID the icon image
   * @param pressedIconImageID the <tt>ImageID</tt> of the image to be used as the icon in the
   *     pressed button state of the new instance
   * @param selected <tt>true</tt> if the new toggle button is to be initially selected; otherwise,
   *     <tt>false</tt>
   * @param inSettingsPanel <tt>true</tt> when the button is used in a menu, to use different
   *     background.
   */
  public InputVolumeControlButton(
      Call call,
      ImageID iconImageID,
      ImageID pressedIconImageID,
      boolean inSettingsPanel,
      boolean selected) {
    super(
        call,
        inSettingsPanel,
        selected,
        iconImageID,
        pressedIconImageID,
        "service.gui.MUTE_BUTTON_TOOL_TIP");

    this.mute = selected;

    volumeControl = getVolumeControl();

    // Creates the menu that would contain the volume control component.
    sliderMenu = new VolumeControlSlider(volumeControl, JSlider.VERTICAL).getPopupMenu();
    sliderMenu.setInvoker(this);

    addMouseListener(
        new MouseAdapter() {
          TimerTask timerTask;

          @Override
          public void mousePressed(MouseEvent mouseevent) {
            Timer timer = new Timer();
            timerTask =
                new TimerTask() {
                  @Override
                  public void run() {
                    showSliderMenu();
                  }
                };

            timer.schedule(timerTask, 1000);
          }

          @Override
          public void mouseReleased(MouseEvent mouseevent) {
            if (!sliderMenuIsVisible) {
              if (timerTask != null) {
                timerTask.cancel();
              }
            } else {
              setSelected(!isSelected());
            }
          }
        });
  }
  /**
   * Shows the appropriate user interface that would allow the user to add the given
   * <tt>SourceUIContact</tt> to their contact list.
   *
   * @param contact the contact to add
   */
  private void addContact(SourceUIContact contact) {
    SourceContact sourceContact = (SourceContact) contact.getDescriptor();

    List<ContactDetail> details =
        sourceContact.getContactDetails(OperationSetPersistentPresence.class);
    int detailsCount = details.size();

    if (detailsCount > 1) {
      JMenuItem addContactMenu =
          TreeContactList.createAddContactMenu((SourceContact) contact.getDescriptor());

      JPopupMenu popupMenu = ((JMenu) addContactMenu).getPopupMenu();

      // Add a title label.
      JLabel infoLabel = new JLabel();
      infoLabel.setText(
          "<html><b>"
              + GuiActivator.getResources().getI18NString("service.gui.ADD_CONTACT")
              + "</b></html>");

      popupMenu.insert(infoLabel, 0);
      popupMenu.insert(new Separator(), 1);

      popupMenu.setFocusable(true);
      popupMenu.setInvoker(treeContactList);

      Point location =
          new Point(
              addContactButton.getX(), addContactButton.getY() + addContactButton.getHeight());

      SwingUtilities.convertPointToScreen(location, treeContactList);

      location.y = location.y + treeContactList.getPathBounds(treeContactList.getSelectionPath()).y;

      popupMenu.setLocation(location.x + 8, location.y - 8);
      popupMenu.setVisible(true);
    } else if (details.size() == 1) {
      TreeContactList.showAddContactDialog(details.get(0), sourceContact.getDisplayName());
    }
  }