/** * Sets the mute status icon to the status panel. * * @param isMute indicates if the call with this peer is muted */ public void setMute(final boolean isMute) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater( new Runnable() { public void run() { setMute(isMute); } }); return; } if (isMute) { muteStatusLabel.setIcon(new ImageIcon(ImageLoader.getImage(ImageLoader.MUTE_STATUS_ICON))); muteStatusLabel.setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 3)); } else { muteStatusLabel.setIcon(null); muteStatusLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); } // Update input volume control button state to reflect the current // mute status. if (localLevel.isSelected() != isMute) localLevel.setSelected(isMute); this.revalidate(); this.repaint(); }
/** Initializes contained components. */ private void initComponents() { final SimpleDateFormat format = new SimpleDateFormat("mm:ss"); final Calendar c = Calendar.getInstance(); final JLabel counter = new JLabel(); counter.setForeground(Color.red); counter.setFont(counter.getFont().deriveFont((float) (counter.getFont().getSize() + 5))); setLayout(new GridBagLayout()); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); GridBagConstraints constraints = new GridBagConstraints(); JLabel messageLabel = new JLabel( GuiActivator.getResources().getI18NString("service.gui.security.SECURITY_ALERT")); messageLabel.setForeground(Color.WHITE); constraints.anchor = GridBagConstraints.CENTER; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 0; constraints.gridy = 0; add(messageLabel, constraints); constraints.anchor = GridBagConstraints.CENTER; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 0; constraints.gridy = 1; add(counter, constraints); ZrtpControl zrtpControl = null; if (securityControl instanceof ZrtpControl) zrtpControl = (ZrtpControl) securityControl; long initialSeconds = 0; if (zrtpControl != null) initialSeconds = zrtpControl.getTimeoutValue(); c.setTimeInMillis(initialSeconds); counter.setText(format.format(c.getTime())); if (initialSeconds > 0) timer.schedule( new TimerTask() { @Override public void run() { if (c.getTimeInMillis() - 1000 > 0) { c.add(Calendar.SECOND, -1); counter.setText(format.format(c.getTime())); } } }, 1000, 1000); }
/** * Creates an instance of <tt>CallManager</tt>. * * @param mainFrame The main application window. */ public CallManager(MainFrame mainFrame) { super(new BorderLayout()); this.mainFrame = mainFrame; this.phoneNumberCombo = new CallComboBox(this); this.accountSelectorBox = new AccountSelectorBox(this); this.buttonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); this.comboPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 5)); this.init(); }
/** * Creates the <tt>Component</tt> hierarchy of the area of status-related information such as * <tt>CallPeer</tt> display name, call duration, security status. * * @return the root of the <tt>Component</tt> hierarchy of the area of status-related information * such as <tt>CallPeer</tt> display name, call duration, security status */ private Component createStatusBar() { // stateLabel callStatusLabel.setForeground(Color.WHITE); dtmfLabel.setForeground(Color.WHITE); callStatusLabel.setText(callPeer.getState().getLocalizedStateString()); PeerStatusPanel statusPanel = new PeerStatusPanel(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; statusPanel.add(securityStatusLabel, constraints); initSecurityStatusLabel(); constraints.gridx++; statusPanel.add(holdStatusLabel, constraints); constraints.gridx++; statusPanel.add(muteStatusLabel, constraints); constraints.gridx++; callStatusLabel.setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 12)); statusPanel.add(callStatusLabel, constraints); constraints.gridx++; constraints.weightx = 1f; statusPanel.add(dtmfLabel, constraints); return statusPanel; }
/** Sets the correct border depending on the contained object. */ private void setBorder() { /* * !!! When changing border values we should make sure that we * recalculate the X and Y coordinates of the buttons added in * initButtonsPanel and initContactActionButtons functions. If not * correctly calculated problems may occur when clicking buttons! */ if (treeNode instanceof ContactNode && !(((ContactNode) treeNode).getContactDescriptor() instanceof ShowMoreContact)) { this.setBorder( BorderFactory.createEmptyBorder(TOP_BORDER, LEFT_BORDER, BOTTOM_BORDER, RIGHT_BORDER)); } else // GroupNode || ShowMoreContact { this.setBorder(BorderFactory.createEmptyBorder(0, LEFT_BORDER, 0, RIGHT_BORDER)); } }
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(); }
/** * Creates the contactlist scroll panel defining the parent frame. * * @param mainFrame The parent frame. */ public ContactListPane(MainFrame mainFrame) { this.mainFrame = mainFrame; this.chatWindowManager = GuiActivator.getUIService().getChatWindowManager(); this.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); this.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, Color.GRAY)); this.initPluginComponents(); }
/** * Sets the "on hold" property value. * * @param isOnHold indicates if the call with this peer is put on hold */ public void setOnHold(final boolean isOnHold) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater( new Runnable() { public void run() { setOnHold(isOnHold); } }); return; } if (isOnHold) { holdStatusLabel.setIcon(new ImageIcon(ImageLoader.getImage(ImageLoader.HOLD_STATUS_ICON))); holdStatusLabel.setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 3)); } else { holdStatusLabel.setIcon(null); holdStatusLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); } this.revalidate(); this.repaint(); }
/** * Initializes the contact list. * * @param contactListService The MetaContactListService which will be used for a contact list data * model. */ public void initList(MetaContactListService contactListService) { this.contactList = new TreeContactList(mainFrame); // We should first set the contact list to the GuiActivator, so that // anybody could get it from there. GuiActivator.setContactList(contactList); // By default we set the current filter to be the presence filter. contactList.applyFilter(TreeContactList.presenceFilter); TransparentPanel transparentPanel = new TransparentPanel(new BorderLayout()); transparentPanel.add(contactList, BorderLayout.NORTH); this.setViewportView(transparentPanel); transparentPanel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); this.contactList.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); this.contactList.addContactListListener(this); this.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { commonRightButtonMenu = new CommonRightButtonMenu(mainFrame); commonRightButtonMenu.setInvoker(ContactListPane.this); commonRightButtonMenu.setLocation( e.getX() + mainFrame.getX() + 5, e.getY() + mainFrame.getY() + 105); commonRightButtonMenu.setVisible(true); } } }); }
/** * Indicates that the security has gone off. * * @param evt the <tt>CallPeerSecurityOffEvent</tt> that notified us */ public void securityOff(final CallPeerSecurityOffEvent evt) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater( new Runnable() { public void run() { securityOff(evt); } }); return; } if (evt.getSessionType() == CallPeerSecurityOffEvent.AUDIO_SESSION) { securityStatusLabel.setText(""); securityStatusLabel.setSecurityOff(); if (securityStatusLabel.getBorder() == null) securityStatusLabel.setBorder(BorderFactory.createEmptyBorder(2, 5, 2, 3)); } securityPanel.securityOff(evt); }
/** Initializes the security status label, shown in the call status bar. */ private void initSecurityStatusLabel() { securityStatusLabel.setBorder(BorderFactory.createEmptyBorder(2, 5, 2, 5)); securityStatusLabel.addMouseListener( new MouseAdapter() { /** Invoked when a mouse button has been pressed on a component. */ @Override public void mousePressed(MouseEvent e) { // Only show the security details if the security is on. SrtpControl ctrl = securityPanel.getSecurityControl(); if (ctrl instanceof ZrtpControl && ctrl.getSecureCommunicationStatus()) { setSecurityPanelVisible( !callRenderer .getCallContainer() .getCallWindow() .getFrame() .getGlassPane() .isVisible()); } } }); }
/** * Prints the given DTMG character through this <tt>CallPeerRenderer</tt>. * * @param dtmfChar the DTMF char to print */ public void printDTMFTone(char dtmfChar) { dtmfLabel.setText(dtmfLabel.getText() + dtmfChar); if (dtmfLabel.getBorder() == null) dtmfLabel.setBorder(BorderFactory.createEmptyBorder(2, 1, 2, 5)); }
/** Init visible components. */ private void init() { TransparentPanel panel = new TransparentPanel(new BorderLayout()); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); // Title label JLabel titleLabel = new JLabel(GuiActivator.getResources().getI18NString("service.gui.avatar.RECENT_ICONS")); titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD)); // fix for displaying text in menu // when using a dark OS theme (as default one in ubuntu) titleLabel.setForeground(new JMenuItem().getForeground()); panel.add(titleLabel, BorderLayout.NORTH); // Init recent images grid TransparentPanel recentImagesGrid = new TransparentPanel(); recentImagesGrid.setLayout(new GridLayout(0, IMAGES_PER_COLUMN)); Dimension thumbsize = new Dimension(THUMB_WIDTH, THUMB_HEIGHT); for (int i = 0; i < MAX_STORED_IMAGES; i++) { this.recentImagesButtons[i] = new SIPCommButton(null); this.recentImagesButtons[i].setBorder(BorderFactory.createEtchedBorder()); this.recentImagesButtons[i].setMaximumSize(thumbsize); this.recentImagesButtons[i].setMinimumSize(thumbsize); this.recentImagesButtons[i].setPreferredSize(thumbsize); this.recentImagesButtons[i].addActionListener(this); this.recentImagesButtons[i].setName("" + i); recentImagesGrid.add(this.recentImagesButtons[i]); } panel.add(recentImagesGrid, BorderLayout.CENTER); // Action buttons TransparentPanel buttonsPanel = new TransparentPanel(); buttonsPanel.setLayout(new GridLayout(0, 1)); // we use this menu item just to get its foreground color. Color linkColor = new JMenuItem().getForeground(); addActionButton( buttonsPanel, this, GuiActivator.getResources().getI18NString("service.gui.avatar.CHOOSE_ICON"), CHOSE_BUTTON_NAME, linkColor); addActionButton( buttonsPanel, this, GuiActivator.getResources().getI18NString("service.gui.avatar.REMOVE_ICON"), REMOVE_BUTTON_NAME, linkColor); addActionButton( buttonsPanel, this, GuiActivator.getResources().getI18NString("service.gui.avatar.CLEAR_RECENT"), CLEAR_BUTTON_NAME, linkColor); panel.add(buttonsPanel, BorderLayout.SOUTH); this.setLayout(new BorderLayout()); this.add(panel, BorderLayout.CENTER); }
/** Initializes this panel. */ private void init() { JPanel mainPanel = new TransparentPanel(new BorderLayout()); mainPanel.setBorder( BorderFactory.createTitledBorder( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sipaccregwizz.CREATE_ACCOUNT_TITLE"))); JPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1)); JPanel valuesPanel = new TransparentPanel(new GridLayout(0, 1)); JLabel usernameLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.USERNAME")); JLabel displayNameLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sipaccregwizz.DISPLAY_NAME")); JLabel passLabel = new JLabel(Sip2SipAccRegWizzActivator.getResources().getI18NString("service.gui.PASSWORD")); JLabel retypePasswordLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.RETYPE_PASSWORD")); JLabel emailLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.EMAIL")); labelsPanel.add(displayNameLabel); labelsPanel.add(usernameLabel); labelsPanel.add(passLabel); labelsPanel.add(retypePasswordLabel); labelsPanel.add(emailLabel); valuesPanel.add(displayNameField); valuesPanel.add(usernameField); valuesPanel.add(passField); valuesPanel.add(retypePassField); valuesPanel.add(emailField); JLabel emailDescriptionLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.EMAIL_NOTE"), SwingConstants.CENTER); emailDescriptionLabel.setForeground(Color.GRAY); emailDescriptionLabel.setFont(emailDescriptionLabel.getFont().deriveFont(8)); emailDescriptionLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 8, 10)); initErrorArea(); mainPanel.add(labelsPanel, BorderLayout.WEST); mainPanel.add(valuesPanel, BorderLayout.CENTER); mainPanel.add(emailDescriptionLabel, BorderLayout.SOUTH); this.add(mainPanel, BorderLayout.CENTER); JLabel infoLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.INFO_NOTE"), SwingConstants.RIGHT); infoLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); infoLabel.setForeground(Color.GRAY); infoLabel.setFont(emailDescriptionLabel.getFont().deriveFont(8)); infoLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0)); infoLabel.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { Sip2SipAccRegWizzActivator.getBrowserLauncher().openURL("http://wiki.sip2sip.info"); } }); this.add(infoLabel, BorderLayout.SOUTH); }
/** Initializes the <tt>NewStatusMessageDialog</tt> by adding the buttons, fields, etc. */ private void init() { JLabel messageLabel = new JLabel(GuiActivator.getResources().getI18NString("service.gui.NEW_STATUS_MESSAGE")); JPanel dataPanel = new TransparentPanel(new BorderLayout(5, 5)); JTextArea infoArea = new JTextArea(GuiActivator.getResources().getI18NString("service.gui.STATUS_MESSAGE_INFO")); JLabel infoTitleLabel = new JLabel(GuiActivator.getResources().getI18NString("service.gui.NEW_STATUS_MESSAGE")); JPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1)); JButton okButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.OK")); JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT)); this.setTitle(GuiActivator.getResources().getI18NString("service.gui.NEW_STATUS_MESSAGE")); this.getRootPane().setDefaultButton(okButton); this.setPreferredSize(new Dimension(500, 200)); infoArea.setEditable(false); infoArea.setLineWrap(true); infoArea.setWrapStyleWord(true); infoArea.setOpaque(false); dataPanel.add(messageLabel, BorderLayout.WEST); messageTextField.setText(presenceOpSet.getCurrentStatusMessage()); dataPanel.add(messageTextField, BorderLayout.CENTER); infoTitleLabel.setHorizontalAlignment(JLabel.CENTER); infoTitleLabel.setFont(infoTitleLabel.getFont().deriveFont(Font.BOLD, 18.0f)); labelsPanel.add(infoTitleLabel); labelsPanel.add(infoArea); labelsPanel.add(dataPanel); messagePanel = new TransparentPanel(new GridBagLayout()); GridBagConstraints messagePanelConstraints = new GridBagConstraints(); messagePanelConstraints.anchor = GridBagConstraints.NORTHWEST; messagePanelConstraints.fill = GridBagConstraints.NONE; messagePanelConstraints.gridx = 0; messagePanelConstraints.gridy = 0; messagePanelConstraints.insets = new Insets(5, 0, 5, 10); messagePanelConstraints.weightx = 0; messagePanelConstraints.weighty = 0; messagePanel.add( new ImageCanvas(ImageLoader.getImage(ImageLoader.RENAME_DIALOG_ICON)), messagePanelConstraints); messagePanelConstraints.anchor = GridBagConstraints.NORTH; messagePanelConstraints.fill = GridBagConstraints.HORIZONTAL; messagePanelConstraints.gridx = 1; messagePanelConstraints.insets = new Insets(0, 0, 0, 0); messagePanelConstraints.weightx = 1; messagePanel.add(labelsPanel, messagePanelConstraints); okButton.setName("ok"); cancelButton.setName("cancel"); okButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.OK")); cancelButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.CANCEL")); okButton.addActionListener(this); cancelButton.addActionListener(this); buttonsPanel.add(okButton); buttonsPanel.add(cancelButton); JPanel mainPanel = new TransparentPanel(new GridBagLayout()); mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 0, 10)); GridBagConstraints mainPanelConstraints = new GridBagConstraints(); mainPanelConstraints.anchor = GridBagConstraints.NORTH; mainPanelConstraints.fill = GridBagConstraints.BOTH; mainPanelConstraints.gridx = 0; mainPanelConstraints.gridy = 0; mainPanelConstraints.weightx = 1; mainPanelConstraints.weighty = 1; mainPanel.add(messagePanel, mainPanelConstraints); mainPanelConstraints.anchor = GridBagConstraints.SOUTHEAST; mainPanelConstraints.fill = GridBagConstraints.NONE; mainPanelConstraints.gridy = 1; mainPanelConstraints.weightx = 0; mainPanelConstraints.weighty = 0; mainPanel.add(buttonsPanel, mainPanelConstraints); this.getContentPane().add(mainPanel); }
/** * Creates an instance of <tt>ShowPreviewDialog</tt> * * @param chatPanel The <tt>ChatConversationPanel</tt> that is associated with this dialog. */ ShowPreviewDialog(final ChatConversationPanel chatPanel) { this.chatPanel = chatPanel; this.setTitle( GuiActivator.getResources().getI18NString("service.gui.SHOW_PREVIEW_DIALOG_TITLE")); okButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.OK")); cancelButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.CANCEL")); JPanel mainPanel = new TransparentPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); // mainPanel.setPreferredSize(new Dimension(200, 150)); this.getContentPane().add(mainPanel); JTextPane descriptionMsg = new JTextPane(); descriptionMsg.setEditable(false); descriptionMsg.setOpaque(false); descriptionMsg.setText( GuiActivator.getResources().getI18NString("service.gui.SHOW_PREVIEW_WARNING_DESCRIPTION")); Icon warningIcon = null; try { warningIcon = new ImageIcon( ImageIO.read( GuiActivator.getResources().getImageURL("service.gui.icons.WARNING_ICON"))); } catch (IOException e) { logger.debug("failed to load the warning icon"); } JLabel warningSign = new JLabel(warningIcon); JPanel warningPanel = new TransparentPanel(); warningPanel.setLayout(new BoxLayout(warningPanel, BoxLayout.X_AXIS)); warningPanel.add(warningSign); warningPanel.add(Box.createHorizontalStrut(10)); warningPanel.add(descriptionMsg); enableReplacement = new JCheckBox( GuiActivator.getResources() .getI18NString("plugin.chatconfig.replacement.ENABLE_REPLACEMENT_STATUS")); enableReplacement.setOpaque(false); enableReplacement.setSelected(cfg.getBoolean(ReplacementProperty.REPLACEMENT_ENABLE, true)); enableReplacementProposal = new JCheckBox( GuiActivator.getResources() .getI18NString("plugin.chatconfig.replacement.ENABLE_REPLACEMENT_PROPOSAL")); enableReplacementProposal.setOpaque(false); JPanel checkBoxPanel = new TransparentPanel(); checkBoxPanel.setLayout(new BoxLayout(checkBoxPanel, BoxLayout.Y_AXIS)); checkBoxPanel.add(enableReplacement); checkBoxPanel.add(enableReplacementProposal); JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER)); buttonsPanel.add(okButton); buttonsPanel.add(cancelButton); mainPanel.add(warningPanel); mainPanel.add(Box.createVerticalStrut(10)); mainPanel.add(checkBoxPanel); mainPanel.add(buttonsPanel); okButton.addActionListener(this); cancelButton.addActionListener(this); this.setPreferredSize(new Dimension(390, 230)); }
/** * Creates an instance of <tt>ConfigListCellRenderer</tt> and specifies that this renderer is * transparent. */ public ConfigListCellRenderer() { this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); this.setOpaque(false); }