/** Inializes button tool tips. */
  private void initButtonToolTips() {
    callButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT"));
    callVideoButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.VIDEO_CALL"));
    desktopSharingButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.SHARE_DESKTOP"));
    chatButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.SEND_MESSAGE"));
    addContactButton.setToolTipText(
        GuiActivator.getResources().getI18NString("service.gui.ADD_CONTACT"));

    // We need to explicitly remove the buttons from the tooltip manager,
    // because we're going to manager the tooltip ourselves in the
    // DefaultTreeContactList class. We need to do this in order to have
    // a different tooltip for every button and for non button area.
    ToolTipManager ttManager = ToolTipManager.sharedInstance();
    ttManager.unregisterComponent(callButton);
    ttManager.unregisterComponent(callVideoButton);
    ttManager.unregisterComponent(desktopSharingButton);
    ttManager.unregisterComponent(chatButton);
    ttManager.unregisterComponent(addContactButton);
  }
예제 #2
0
  /**
   * Sets the button icon according to the passed in {@link SessionStatus}.
   *
   * @param status the {@link SessionStatus}.
   */
  private void setStatus(ScSessionStatus status) {
    animatedPadlockImage.pause();
    Image image;
    String tipKey;
    switch (status) {
      case ENCRYPTED:
        PublicKey pubKey = OtrActivator.scOtrEngine.getRemotePublicKey(otrContact);
        String fingerprint = OtrActivator.scOtrKeyManager.getFingerprintFromPublicKey(pubKey);
        image =
            OtrActivator.scOtrKeyManager.isVerified(otrContact.contact, fingerprint)
                ? verifiedLockedPadlockImage
                : unverifiedLockedPadlockImage;
        tipKey =
            OtrActivator.scOtrKeyManager.isVerified(otrContact.contact, fingerprint)
                ? "plugin.otr.menu.VERIFIED"
                : "plugin.otr.menu.UNVERIFIED";
        break;
      case FINISHED:
        image = finishedPadlockImage;
        tipKey = "plugin.otr.menu.FINISHED";
        break;
      case PLAINTEXT:
        image = unlockedPadlockImage;
        tipKey = "plugin.otr.menu.START_OTR";
        break;
      case LOADING:
        image = animatedPadlockImage;
        animatedPadlockImage.start();
        tipKey = "plugin.otr.menu.LOADING_OTR";
        break;
      case TIMED_OUT:
        image = timedoutPadlockImage;
        tipKey = "plugin.otr.menu.TIMED_OUT";
        break;
      default:
        return;
    }

    SIPCommButton button = getButton();
    button.setIconImage(image);
    button.setToolTipText(OtrActivator.resourceService.getI18NString(tipKey));
    button.repaint();
  }
예제 #3
0
  /**
   * Gets the <code>SIPCommButton</code> which is the component of this plugin. If the button
   * doesn't exist, it's created.
   *
   * @return the <code>SIPCommButton</code> which is the component of this plugin
   */
  @SuppressWarnings("fallthrough")
  private SIPCommButton getButton() {
    if (button == null) {
      button = new SIPCommButton(null, null);
      button.setEnabled(false);
      button.setPreferredSize(new Dimension(25, 25));

      button.setToolTipText(
          OtrActivator.resourceService.getI18NString("plugin.otr.menu.OTR_TOOLTIP"));

      Image i1 = null, i2 = null, i3 = null;
      try {
        i1 =
            ImageIO.read(
                OtrActivator.resourceService.getImageURL("plugin.otr.LOADING_ICON1_22x22"));
        i2 =
            ImageIO.read(
                OtrActivator.resourceService.getImageURL("plugin.otr.LOADING_ICON2_22x22"));
        i3 =
            ImageIO.read(
                OtrActivator.resourceService.getImageURL("plugin.otr.LOADING_ICON3_22x22"));
        finishedPadlockImage =
            ImageIO.read(
                OtrActivator.resourceService.getImageURL("plugin.otr.FINISHED_ICON_22x22"));
        verifiedLockedPadlockImage =
            ImageIO.read(
                OtrActivator.resourceService.getImageURL("plugin.otr.ENCRYPTED_ICON_22x22"));
        unverifiedLockedPadlockImage =
            ImageIO.read(
                OtrActivator.resourceService.getImageURL(
                    "plugin.otr.ENCRYPTED_UNVERIFIED_ICON_22x22"));
        unlockedPadlockImage =
            ImageIO.read(
                OtrActivator.resourceService.getImageURL("plugin.otr.PLAINTEXT_ICON_22x22"));
        timedoutPadlockImage =
            ImageIO.read(OtrActivator.resourceService.getImageURL("plugin.otr.BROKEN_ICON_22x22"));
      } catch (IOException e) {
        logger.debug("Failed to load padlock image");
      }

      animatedPadlockImage = new AnimatedImage(button, i1, i2, i3);

      button.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              if (otrContact == null) return;

              switch (OtrActivator.scOtrEngine.getSessionStatus(otrContact)) {
                case ENCRYPTED:
                  OtrPolicy policy = OtrActivator.scOtrEngine.getContactPolicy(otrContact.contact);
                  policy.setSendWhitespaceTag(false);
                  OtrActivator.scOtrEngine.setContactPolicy(otrContact.contact, policy);
                case FINISHED:
                case LOADING:
                  // Default action for finished, encrypted and loading
                  // sessions is end session.
                  OtrActivator.scOtrEngine.endSession(otrContact);
                  break;
                case TIMED_OUT:
                case PLAINTEXT:
                  policy = OtrActivator.scOtrEngine.getContactPolicy(otrContact.contact);
                  OtrPolicy globalPolicy = OtrActivator.scOtrEngine.getGlobalPolicy();
                  policy.setSendWhitespaceTag(globalPolicy.getSendWhitespaceTag());
                  OtrActivator.scOtrEngine.setContactPolicy(otrContact.contact, policy);
                  // Default action for timed_out and plaintext sessions
                  // is start session.
                  OtrActivator.scOtrEngine.startSession(otrContact);
                  break;
              }
            }
          });
    }
    return button;
  }