/** Initializes the panel containing the node. */ public ContactListTreeCellRenderer() { super(new GridBagLayout()); loadSkin(); this.setOpaque(true); this.nameLabel.setOpaque(false); this.displayDetailsLabel.setFont(getFont().deriveFont(9f)); this.displayDetailsLabel.setForeground(Color.GRAY); this.rightLabel.setHorizontalAlignment(JLabel.RIGHT); // !! IMPORTANT: General insets used for all components if not // overwritten! constraints.insets = new Insets(0, 0, 0, H_GAP); constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 0; constraints.gridy = 0; constraints.gridheight = 1; constraints.weightx = 0f; constraints.weighty = 1f; this.add(statusLabel, constraints); addLabels(1); callButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (treeNode != null && treeNode instanceof ContactNode) { call(treeNode, callButton, false, false); } } }); callVideoButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (treeNode != null && treeNode instanceof ContactNode) { call(treeNode, callVideoButton, true, false); } } }); desktopSharingButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (treeNode != null && treeNode instanceof ContactNode) { call(treeNode, desktopSharingButton, true, true); } } }); chatButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (treeNode != null && treeNode instanceof ContactNode) { UIContact contactDescriptor = ((ContactNode) treeNode).getContactDescriptor(); if (contactDescriptor.getDescriptor() instanceof MetaContact) { GuiActivator.getUIService() .getChatWindowManager() .startChat((MetaContact) contactDescriptor.getDescriptor()); } } } }); addContactButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (treeNode != null && treeNode instanceof ContactNode) { UIContact contactDescriptor = ((ContactNode) treeNode).getContactDescriptor(); // The add contact function has only sense for external // source contacts. if (contactDescriptor instanceof SourceUIContact) { addContact((SourceUIContact) contactDescriptor); } } } }); initButtonToolTips(); this.setToolTipText(""); }
/** * 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; }