/** * Adds contact entry labels. * * @param nameLabelGridWidth the grid width of the contact entry name label */ private void addLabels(int nameLabelGridWidth) { remove(nameLabel); remove(rightLabel); remove(displayDetailsLabel); if (treeNode != null && !(treeNode instanceof GroupNode)) constraints.insets = new Insets(0, 0, V_GAP, H_GAP); else constraints.insets = new Insets(0, 0, 0, H_GAP); constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 0; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridheight = 1; constraints.gridwidth = nameLabelGridWidth; this.add(nameLabel, constraints); constraints.anchor = GridBagConstraints.NORTHEAST; constraints.fill = GridBagConstraints.VERTICAL; constraints.gridx = nameLabelGridWidth + 1; constraints.gridy = 0; constraints.gridheight = 3; constraints.weightx = 0f; constraints.weighty = 1f; this.add(rightLabel, constraints); if (treeNode != null && treeNode instanceof ContactNode) { constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 1; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridwidth = nameLabelGridWidth; constraints.gridheight = 1; this.add(displayDetailsLabel, constraints); } else if (treeNode != null && treeNode instanceof GroupNode) { constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 1; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridwidth = nameLabelGridWidth; constraints.gridheight = 1; this.add(displayDetailsLabel, constraints); } }
private int addButton(SIPCommButton button, int gridX, int xBounds, boolean isLast) { lastAddedButton = button; constraints.insets = new Insets(0, 0, V_GAP, 0); constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = gridX; constraints.gridy = 2; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0f; constraints.weighty = 0f; this.add(button, constraints); int yBounds = TOP_BORDER + BOTTOM_BORDER + 2 * V_GAP + ComponentUtils.getStringSize(nameLabel, nameLabel.getText()).height + ComponentUtils.getStringSize(displayDetailsLabel, displayDetailsLabel.getText()) .height; button.setBounds(xBounds, yBounds, BUTTON_WIDTH, BUTTON_HEIGHT); button.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); setButtonBg(button, gridX, isLast); return button.getWidth(); }
/** * Initializes the display details component for the given <tt>UIContact</tt>. * * @param displayDetails the display details to show */ private void initDisplayDetails(String displayDetails) { remove(displayDetailsLabel); displayDetailsLabel.setText(""); if (displayDetails != null && displayDetails.length() > 0) { // Replace all occurrences of new line with slash. displayDetails = Html2Text.extractText(displayDetails); displayDetails = displayDetails.replaceAll("\n|<br>|<br/>", " / "); displayDetailsLabel.setText(displayDetails); } constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 1; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridwidth = 1; constraints.gridheight = 1; this.add(displayDetailsLabel, constraints); }
/** 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(""); }
private void initComponents() { setLayout(new BorderLayout()); final JPanel mainPanel = new TransparentPanel(); add(mainPanel, BorderLayout.NORTH); mainPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; c.fill = GridBagConstraints.HORIZONTAL; // general encryption option enableDefaultEncryption = new SIPCommCheckBox( UtilActivator.getResources() .getI18NString("plugin.sipaccregwizz.ENABLE_DEFAULT_ENCRYPTION"), regform.isDefaultEncryption()); enableDefaultEncryption.addActionListener(this); mainPanel.add(enableDefaultEncryption, c); // warning message and button to show advanced options JLabel lblWarning = new JLabel(); lblWarning.setBorder(new EmptyBorder(10, 5, 10, 0)); lblWarning.setText( UtilActivator.getResources() .getI18NString( "plugin.sipaccregwizz.SECURITY_WARNING", new String[] { UtilActivator.getResources().getSettingsString("service.gui.APPLICATION_NAME") })); c.gridy++; mainPanel.add(lblWarning, c); cmdExpandAdvancedSettings = new JLabel(); cmdExpandAdvancedSettings.setBorder(new EmptyBorder(0, 5, 0, 0)); cmdExpandAdvancedSettings.setIcon( UtilActivator.getResources().getImage("service.gui.icons.RIGHT_ARROW_ICON")); cmdExpandAdvancedSettings.setText( UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.SHOW_ADVANCED")); cmdExpandAdvancedSettings.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { cmdExpandAdvancedSettings.setIcon( UtilActivator.getResources() .getImage( pnlAdvancedSettings.isVisible() ? "service.gui.icons.RIGHT_ARROW_ICON" : "service.gui.icons.DOWN_ARROW_ICON")); pnlAdvancedSettings.setVisible(!pnlAdvancedSettings.isVisible()); pnlAdvancedSettings.revalidate(); } }); c.gridy++; mainPanel.add(cmdExpandAdvancedSettings, c); pnlAdvancedSettings = new TransparentPanel(); pnlAdvancedSettings.setLayout(new GridBagLayout()); pnlAdvancedSettings.setVisible(false); c.gridy++; mainPanel.add(pnlAdvancedSettings, c); c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.gridwidth = 2; c.gridheight = 1; c.anchor = GridBagConstraints.LINE_START; c.fill = GridBagConstraints.HORIZONTAL; pnlAdvancedSettings.add(new JSeparator(), c); // Encryption protcol preferences. JLabel lblEncryptionProtocolPreferences = new JLabel(); lblEncryptionProtocolPreferences.setText( UtilActivator.getResources() .getI18NString("plugin.sipaccregwizz.ENCRYPTION_PROTOCOL_PREFERENCES")); c.gridy++; pnlAdvancedSettings.add(lblEncryptionProtocolPreferences, c); int nbEncryptionProtocols = ENCRYPTION_PROTOCOLS.length; String[] encryptions = new String[nbEncryptionProtocols]; boolean[] selectedEncryptions = new boolean[nbEncryptionProtocols]; this.encryptionConfigurationTableModel = new EncryptionConfigurationTableModel(encryptions, selectedEncryptions); loadEncryptionProtocols(new HashMap<String, Integer>(), new HashMap<String, Boolean>()); this.encryptionProtocolPreferences = new PriorityTable(this.encryptionConfigurationTableModel, 60); this.encryptionConfigurationTableModel.addTableModelListener(this); c.gridy++; pnlAdvancedSettings.add(this.encryptionProtocolPreferences, c); // ZRTP JLabel lblZrtpOption = new JLabel(); lblZrtpOption.setBorder(new EmptyBorder(5, 5, 5, 0)); lblZrtpOption.setText( UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.ZRTP_OPTION")); c.gridx = 0; c.gridy++; c.gridwidth = 1; pnlAdvancedSettings.add(lblZrtpOption, c); c.gridx = 1; pnlAdvancedSettings.add(new JSeparator(), c); enableSipZrtpAttribute = new SIPCommCheckBox( UtilActivator.getResources() .getI18NString("plugin.sipaccregwizz.ENABLE_SIPZRTP_ATTRIBUTE"), regform.isSipZrtpAttribute()); c.gridx = 0; c.gridy++; c.gridwidth = 2; pnlAdvancedSettings.add(enableSipZrtpAttribute, c); // SDES JLabel lblSDesOption = new JLabel(); lblSDesOption.setBorder(new EmptyBorder(5, 5, 5, 0)); lblSDesOption.setText( UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.SDES_OPTION")); c.gridx = 0; c.gridy++; c.gridwidth = 1; pnlAdvancedSettings.add(lblSDesOption, c); c.gridx = 1; pnlAdvancedSettings.add(new JSeparator(), c); JLabel lblCipherInfo = new JLabel(); lblCipherInfo.setText( UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.CIPHER_SUITES")); c.gridx = 0; c.gridy++; c.gridwidth = 2; pnlAdvancedSettings.add(lblCipherInfo, c); cipherModel = new CipherTableModel(regform.getSDesCipherSuites()); tabCiphers = new JTable(cipherModel); tabCiphers.setShowGrid(false); tabCiphers.setTableHeader(null); TableColumnModel tableColumnModel = tabCiphers.getColumnModel(); TableColumn tableColumn = tableColumnModel.getColumn(0); tableColumn.setMaxWidth(tableColumn.getMinWidth()); JScrollPane scrollPane = new JScrollPane(tabCiphers); scrollPane.setPreferredSize(new Dimension(tabCiphers.getWidth(), 100)); c.gridy++; pnlAdvancedSettings.add(scrollPane, c); // SAVP selection c.gridx = 0; c.gridwidth = 1; JLabel lblSavpOption = new JLabel(); lblSavpOption.setBorder(new EmptyBorder(5, 5, 5, 0)); lblSavpOption.setText( UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.SAVP_OPTION")); if (this.displaySavpOtions) { c.gridy++; pnlAdvancedSettings.add(lblSavpOption, c); } c.gridx = 1; if (this.displaySavpOtions) { pnlAdvancedSettings.add(new JSeparator(), c); } cboSavpOption = new JComboBox(new SavpOption[] {new SavpOption(0), new SavpOption(1), new SavpOption(2)}); c.gridx = 0; c.gridwidth = 2; c.insets = new Insets(0, 20, 0, 0); if (this.displaySavpOtions) { c.gridy++; pnlAdvancedSettings.add(cboSavpOption, c); } }