/** * Called to indicate that sending typing notification has failed. * * @param evt a <tt>TypingNotificationEvent</tt> containing the sender of the notification and its * type. */ public void typingNotificationDeliveryFailed(TypingNotificationEvent evt) { if (typingTimer.isRunning()) typingTimer.stop(); String notificationMsg = ""; MetaContact metaContact = GuiActivator.getContactListService().findMetaContactByContact(evt.getSourceContact()); String contactName = metaContact.getDisplayName(); if (contactName.equals("")) { contactName = GuiActivator.getResources().getI18NString("service.gui.UNKNOWN") + " "; } ChatPanel chatPanel = chatWindowManager.getContactChat(metaContact, false); notificationMsg = GuiActivator.getResources() .getI18NString("service.gui.CONTACT_TYPING_SEND_FAILED", new String[] {contactName}); // Proactive typing notification if (!chatWindowManager.isChatOpenedFor(metaContact)) { return; } if (chatPanel != null) chatPanel.addErrorSendingTypingNotification(notificationMsg); typingTimer.setMetaContact(metaContact); typingTimer.start(); }
/** 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); }
/** Reloads button resources. */ public void loadSkin() { addButton.setIcon( GuiActivator.getResources().getImage("service.gui.icons.ADD_CONTACT_16x16_ICON")); callButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.CALL_16x16_ICON")); if (smsButton != null) smsButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.SMS_BUTTON_ICON")); }
/** * Creates the buttons panel. * * @return the buttons panel */ private Component createButtonsPanel() { JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.OK")); okButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { selectedDevice = (MediaDevice) deviceComboBox.getSelectedItem(); dispose(); } }); buttonsPanel.add(okButton); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { selectedDevice = null; dispose(); } }); buttonsPanel.add(cancelButton); return buttonsPanel; }
/** Initializes the call button. */ private void initCallButton() { List<ProtocolProviderService> telephonyProviders = CallManager.getTelephonyProviders(); if (telephonyProviders != null && telephonyProviders.size() > 0) { if (callButton.getParent() != null) return; callButton.setAlignmentX(JButton.CENTER_ALIGNMENT); callButton.setMnemonic( GuiActivator.getResources().getI18nMnemonic("service.gui.CALL_CONTACT")); buttonPanel.add(callButton); callButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String searchText = parentWindow.getCurrentSearchText(); if (searchText == null) return; CallManager.createCall(searchText, callButton); } }); } else { buttonPanel.remove(callButton); } }
/** * Informs the user what is the typing state of his chat contacts. * * @param evt the event containing details on the typing notification */ public void typingNotificationReceived(TypingNotificationEvent evt) { if (typingTimer.isRunning()) typingTimer.stop(); String notificationMsg = ""; MetaContact metaContact = GuiActivator.getContactListService().findMetaContactByContact(evt.getSourceContact()); String contactName = metaContact.getDisplayName() + " "; if (contactName.equals("")) { contactName = GuiActivator.getResources().getI18NString("service.gui.UNKNOWN") + " "; } int typingState = evt.getTypingState(); ChatPanel chatPanel = chatWindowManager.getContactChat(metaContact, false); if (typingState == OperationSetTypingNotifications.STATE_TYPING) { notificationMsg = GuiActivator.getResources() .getI18NString("service.gui.CONTACT_TYPING", new String[] {contactName}); // Proactive typing notification if (!chatWindowManager.isChatOpenedFor(metaContact)) { return; } if (chatPanel != null) chatPanel.addTypingNotification(notificationMsg); typingTimer.setMetaContact(metaContact); typingTimer.start(); } else if (typingState == OperationSetTypingNotifications.STATE_PAUSED) { notificationMsg = GuiActivator.getResources() .getI18NString("service.gui.CONTACT_PAUSED_TYPING", new String[] {contactName}); if (chatPanel != null) chatPanel.addTypingNotification(notificationMsg); typingTimer.setMetaContact(metaContact); typingTimer.start(); } else { if (chatPanel != null) chatPanel.removeTypingNotification(); } }
/** Loads all images and colors. */ public void loadSkin() { openedGroupIcon = new ImageIcon(ImageLoader.getImage(ImageLoader.OPENED_GROUP_ICON)); closedGroupIcon = new ImageIcon(ImageLoader.getImage(ImageLoader.CLOSED_GROUP_ICON)); callButton.setIconImage(ImageLoader.getImage(ImageLoader.CALL_BUTTON_SMALL)); callButton.setRolloverIcon(ImageLoader.getImage(ImageLoader.CALL_BUTTON_SMALL_ROLLOVER)); callButton.setPressedIcon(ImageLoader.getImage(ImageLoader.CALL_BUTTON_SMALL_PRESSED)); chatButton.setIconImage(ImageLoader.getImage(ImageLoader.CHAT_BUTTON_SMALL)); chatButton.setRolloverIcon(ImageLoader.getImage(ImageLoader.CHAT_BUTTON_SMALL_ROLLOVER)); chatButton.setPressedIcon(ImageLoader.getImage(ImageLoader.CHAT_BUTTON_SMALL_PRESSED)); msgReceivedImage = ImageLoader.getImage(ImageLoader.MESSAGE_RECEIVED_ICON); int groupForegroundProperty = GuiActivator.getResources().getColor("service.gui.CONTACT_LIST_GROUP_FOREGROUND"); if (groupForegroundProperty > -1) groupForegroundColor = new Color(groupForegroundProperty); int contactForegroundProperty = GuiActivator.getResources().getColor("service.gui.CONTACT_LIST_CONTACT_FOREGROUND"); if (contactForegroundProperty > -1) contactForegroundColor = new Color(contactForegroundProperty); callVideoButton.setIconImage(ImageLoader.getImage(ImageLoader.CALL_VIDEO_BUTTON_SMALL)); callVideoButton.setRolloverIcon( ImageLoader.getImage(ImageLoader.CALL_VIDEO_BUTTON_SMALL_ROLLOVER)); callVideoButton.setPressedIcon( ImageLoader.getImage(ImageLoader.CALL_VIDEO_BUTTON_SMALL_PRESSED)); desktopSharingButton.setIconImage(ImageLoader.getImage(ImageLoader.DESKTOP_BUTTON_SMALL)); desktopSharingButton.setRolloverIcon( ImageLoader.getImage(ImageLoader.DESKTOP_BUTTON_SMALL_ROLLOVER)); desktopSharingButton.setPressedIcon( ImageLoader.getImage(ImageLoader.DESKTOP_BUTTON_SMALL_PRESSED)); addContactButton.setIconImage(ImageLoader.getImage(ImageLoader.ADD_CONTACT_BUTTON_SMALL)); addContactButton.setRolloverIcon( ImageLoader.getImage(ImageLoader.ADD_CONTACT_BUTTON_SMALL_ROLLOVER)); addContactButton.setPressedIcon( ImageLoader.getImage(ImageLoader.ADD_CONTACT_BUTTON_SMALL_PRESSED)); }
/** Sets the names of the call buttons depending on the chat session type. */ private void setCallButtonsName() { if (chatSession instanceof ConferenceChatSession) { callButton.setName("createConference"); callVideoButton.setName("createConference"); this.callButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.CREATE_JOIN_VIDEO_CONFERENCE")); this.callVideoButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.CREATE_JOIN_VIDEO_CONFERENCE")); } else { callButton.setName("call"); callVideoButton.setName("callVideo"); this.callButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT")); this.callVideoButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT")); } }
/** * Returns the display details for the underlying <tt>MetaContact</tt>. * * @return the display details for the underlying <tt>MetaContact</tt> */ public String getDisplayDetails() { String displayDetails = null; Iterator<Contact> protoContacts = metaContact.getContacts(); String subscriptionDetails = null; while (protoContacts.hasNext()) { Contact protoContact = protoContacts.next(); OperationSetExtendedAuthorizations authOpSet = protoContact .getProtocolProvider() .getOperationSet(OperationSetExtendedAuthorizations.class); if (authOpSet != null && authOpSet.getSubscriptionStatus(protoContact) != null && !authOpSet.getSubscriptionStatus(protoContact).equals(SubscriptionStatus.Subscribed)) { SubscriptionStatus status = authOpSet.getSubscriptionStatus(protoContact); if (status.equals(SubscriptionStatus.SubscriptionPending)) subscriptionDetails = GuiActivator.getResources().getI18NString("service.gui.WAITING_AUTHORIZATION"); else if (status.equals(SubscriptionStatus.NotSubscribed)) subscriptionDetails = GuiActivator.getResources().getI18NString("service.gui.NOT_AUTHORIZED"); } else if (protoContact.getStatusMessage() != null && protoContact.getStatusMessage().length() > 0) { subscribed = true; displayDetails = protoContact.getStatusMessage(); break; } else { subscribed = true; } } if ((displayDetails == null || displayDetails.length() <= 0) && !subscribed && subscriptionDetails != null && subscriptionDetails.length() > 0) displayDetails = subscriptionDetails; return displayDetails; }
/** * Updates the text area to take into account the new search text. * * @param searchText the search text to update */ private void updateTextArea(String searchText) { if (callButton.getParent() != null) { textArea.setText( GuiActivator.getResources() .getI18NString( "service.gui.NO_CONTACTS_FOUND", new String[] {'"' + searchText + '"'})); this.revalidate(); this.repaint(); } }
/** * The handler for the security event received. The security event for starting establish a secure * connection. * * @param evt the security started event received */ public void securityNegotiationStarted(CallPeerSecurityNegotiationStartedEvent evt) { if (Boolean.parseBoolean( GuiActivator.getResources().getSettingsString("impl.gui.PARANOIA_UI"))) { SrtpControl srtpControl = null; if (callPeer instanceof MediaAwareCallPeer) srtpControl = evt.getSecurityController(); securityPanel = new ParanoiaTimerSecurityPanel<SrtpControl>(srtpControl); setSecurityPanelVisible(true); } }
/** Initializes the call button. */ private void initSMSButton() { if (!parentWindow.hasOperationSet(OperationSetSmsMessaging.class)) return; smsButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.SEND_SMS")); smsButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.SMS_BUTTON_ICON")); buttonPanel.add(smsButton); smsButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final String searchText = parentWindow.getCurrentSearchText(); if (searchText == null) return; SMSManager.sendSMS(smsButton, searchText); } }); }
/** * Creates the <tt>UnknownContactPanel</tt> by specifying the parent window. * * @param window the parent window */ public UnknownContactPanel(MainFrame window) { super(new BorderLayout()); this.parentWindow = window; TransparentPanel mainPanel = new TransparentPanel(new BorderLayout()); this.add(mainPanel, BorderLayout.NORTH); if (!ConfigurationUtils.isAddContactDisabled()) { initAddContactButton(); } initCallButton(); initSMSButton(); initTextArea(); mainPanel.add(textArea, BorderLayout.CENTER); if (callButton.getParent() != null) { textArea.setText( GuiActivator.getResources() .getI18NString( "service.gui.NO_CONTACTS_FOUND", new String[] {'"' + parentWindow.getCurrentSearchText() + '"'})); } else { textArea.setText( GuiActivator.getResources().getI18NString("service.gui.NO_CONTACTS_FOUND_SHORT")); } if (buttonPanel.getComponentCount() > 0) { TransparentPanel southPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER)); southPanel.add(buttonPanel); mainPanel.add(southPanel, BorderLayout.SOUTH); } loadSkin(); }
/** 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); }
private void initSmiliesSelectorBox() { this.smileysBox = new SmileysSelectorBox(); this.smileysBox.setName("smiley"); this.smileysBox.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.INSERT_SMILEY") + " Ctrl-M"); SIPCommMenuBar smileyMenuBar = new SIPCommMenuBar(); smileyMenuBar.setOpaque(false); smileyMenuBar.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); smileyMenuBar.add(smileysBox); this.add(smileyMenuBar); }
private void initAddContactButton() { addButton.setAlignmentX(JButton.CENTER_ALIGNMENT); addButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.ADD_CONTACT")); buttonPanel.add(addButton); addButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { AddContactDialog dialog = new AddContactDialog(parentWindow); dialog.setContactAddress(parentWindow.getCurrentSearchText()); dialog.setVisible(true); } }); }
/** * Shows a warning message to the user when message delivery has failed. * * @param evt the event containing details on the message delivery failure */ public void messageDeliveryFailed(MessageDeliveryFailedEvent evt) { logger.error(evt.getReason()); String errorMsg = null; Message sourceMessage = (Message) evt.getSource(); Contact sourceContact = evt.getDestinationContact(); MetaContact metaContact = GuiActivator.getContactListService().findMetaContactByContact(sourceContact); if (evt.getErrorCode() == MessageDeliveryFailedEvent.OFFLINE_MESSAGES_NOT_SUPPORTED) { errorMsg = GuiActivator.getResources() .getI18NString( "service.gui.MSG_DELIVERY_NOT_SUPPORTED", new String[] {sourceContact.getDisplayName()}); } else if (evt.getErrorCode() == MessageDeliveryFailedEvent.NETWORK_FAILURE) { errorMsg = GuiActivator.getResources().getI18NString("service.gui.MSG_NOT_DELIVERED"); } else if (evt.getErrorCode() == MessageDeliveryFailedEvent.PROVIDER_NOT_REGISTERED) { errorMsg = GuiActivator.getResources().getI18NString("service.gui.MSG_SEND_CONNECTION_PROBLEM"); } else if (evt.getErrorCode() == MessageDeliveryFailedEvent.INTERNAL_ERROR) { errorMsg = GuiActivator.getResources().getI18NString("service.gui.MSG_DELIVERY_INTERNAL_ERROR"); } else { errorMsg = GuiActivator.getResources().getI18NString("service.gui.MSG_DELIVERY_ERROR"); } String reason = evt.getReason(); if (reason != null) errorMsg += " " + GuiActivator.getResources() .getI18NString("service.gui.ERROR_WAS", new String[] {reason}); ChatPanel chatPanel = chatWindowManager.getContactChat(metaContact, sourceContact); chatPanel.addMessage( sourceContact.getAddress(), metaContact.getDisplayName(), new Date(), Chat.OUTGOING_MESSAGE, sourceMessage.getContent(), sourceMessage.getContentType(), sourceMessage.getMessageUID(), evt.getCorrectedMessageUID()); chatPanel.addErrorMessage(metaContact.getDisplayName(), errorMsg); chatWindowManager.openChat(chatPanel, false); }
/** * When a sent message is delivered shows it in the chat conversation panel. * * @param evt the event containing details on the message delivery */ public void messageDelivered(MessageDeliveredEvent evt) { Contact contact = evt.getDestinationContact(); MetaContact metaContact = GuiActivator.getContactListService().findMetaContactByContact(contact); if (logger.isTraceEnabled()) logger.trace("MESSAGE DELIVERED to contact: " + contact.getAddress()); ChatPanel chatPanel = chatWindowManager.getContactChat(metaContact, false); if (chatPanel != null) { Message msg = evt.getSourceMessage(); ProtocolProviderService protocolProvider = contact.getProtocolProvider(); if (logger.isTraceEnabled()) logger.trace( "MESSAGE DELIVERED: process message to chat for contact: " + contact.getAddress() + " MESSAGE: " + msg.getContent()); chatPanel.addMessage( this.mainFrame.getAccountAddress(protocolProvider), this.mainFrame.getAccountDisplayName(protocolProvider), evt.getTimestamp(), Chat.OUTGOING_MESSAGE, msg.getContent(), msg.getContentType(), msg.getMessageUID(), evt.getCorrectedMessageUID()); if (evt.isSmsMessage() && !ConfigurationUtils.isSmsNotifyTextDisabled()) { chatPanel.addMessage( contact.getDisplayName(), new Date(), Chat.ACTION_MESSAGE, GuiActivator.getResources().getI18NString("service.gui.SMS_SUCCESSFULLY_SENT"), "text"); } } }
/** * 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()); } }
/** 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); }
/** Initializes this component. */ protected void init() { this.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0)); this.setOpaque(false); this.add(inviteButton); // if we leave a chat room when we close the window // there is no need for this button if (!ConfigurationUtils.isLeaveChatRoomOnWindowCloseEnabled()) this.add(leaveChatRoomButton); this.add(callButton); this.add(callVideoButton); this.add(desktopSharingButton); this.add(sendFileButton); ChatPanel chatPanel = chatContainer.getCurrentChat(); if (chatPanel == null || !(chatPanel.getChatSession() instanceof MetaContactChatSession)) sendFileButton.setEnabled(false); this.addSeparator(); this.add(historyButton); this.add(previousButton); this.add(nextButton); // We only add the options button if the property SHOW_OPTIONS_WINDOW // specifies so or if it's not set. Boolean showOptionsProp = GuiActivator.getConfigurationService() .getBoolean(ConfigurationFrame.SHOW_OPTIONS_WINDOW_PROPERTY, false); if (showOptionsProp.booleanValue()) { this.add(optionsButton); } this.addSeparator(); if (ConfigurationUtils.isFontSupportEnabled()) { this.add(fontButton); fontButton.setName("font"); fontButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.CHANGE_FONT")); fontButton.addActionListener(this); } initSmiliesSelectorBox(); this.addSeparator(); this.inviteButton.setName("invite"); this.inviteButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.INVITE")); this.leaveChatRoomButton.setName("leave"); this.leaveChatRoomButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.LEAVE")); this.callButton.setName("call"); this.callButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT")); this.callVideoButton.setName("callVideo"); this.callVideoButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT")); this.desktopSharingButton.setName("desktop"); this.desktopSharingButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.SHARE_DESKTOP_WITH_CONTACT")); this.historyButton.setName("history"); this.historyButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.HISTORY") + " Ctrl-H"); optionsButton.setName("options"); optionsButton.setToolTipText(GuiActivator.getResources().getI18NString("service.gui.OPTIONS")); this.sendFileButton.setName("sendFile"); this.sendFileButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.SEND_FILE")); this.previousButton.setName("previous"); this.previousButton.setToolTipText( GuiActivator.getResources().getI18NString("service.gui.PREVIOUS")); this.nextButton.setName("next"); this.nextButton.setToolTipText(GuiActivator.getResources().getI18NString("service.gui.NEXT")); inviteButton.addActionListener(this); leaveChatRoomButton.addActionListener(this); callButton.addActionListener(this); callVideoButton.addActionListener(this); desktopSharingButton.addActionListener(this); historyButton.addActionListener(this); optionsButton.addActionListener(this); sendFileButton.addActionListener(this); previousButton.addActionListener(this); nextButton.addActionListener(this); }
/** * Indicates that the security is turned on. * * <p>Sets the secured status icon to the status panel and initializes/updates the corresponding * security details. * * @param evt Details about the event that caused this message. */ public void securityOn(final CallPeerSecurityOnEvent evt) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater( new Runnable() { public void run() { securityOn(evt); } }); return; } // If the securityOn is called without a specific event, we'll just set // the security label status to on. if (evt == null) { securityStatusLabel.setSecurityOn(); return; } SrtpControl srtpControl = evt.getSecurityController(); if (!srtpControl.requiresSecureSignalingTransport() || callPeer.getProtocolProvider().isSignalingTransportSecure()) { if (srtpControl instanceof ZrtpControl) { securityStatusLabel.setText("zrtp"); if (!((ZrtpControl) srtpControl).isSecurityVerified()) securityStatusLabel.setSecurityPending(); else securityStatusLabel.setSecurityOn(); } else securityStatusLabel.setSecurityOn(); } // if we have some other panel, using other control if (!srtpControl.getClass().isInstance(securityPanel.getSecurityControl()) || (securityPanel instanceof ParanoiaTimerSecurityPanel)) { setSecurityPanelVisible(false); securityPanel = SecurityPanel.create(this, callPeer, srtpControl); if (srtpControl instanceof ZrtpControl) ((ZrtpSecurityPanel) securityPanel).setSecurityStatusLabel(securityStatusLabel); } securityPanel.securityOn(evt); boolean isSecurityLowPriority = Boolean.parseBoolean( GuiActivator.getResources() .getSettingsString("impl.gui.I_DONT_CARE_THAT_MUCH_ABOUT_SECURITY")); // Display ZRTP panel in case SAS was not verified or a AOR mismtach // was detected during creation of ZrtpSecurityPanel. // Don't show panel if user does not care about security at all. if (srtpControl instanceof ZrtpControl && !isSecurityLowPriority && (!((ZrtpControl) srtpControl).isSecurityVerified() || ((ZrtpSecurityPanel) securityPanel).isZidAorMismatch())) { setSecurityPanelVisible(true); } this.revalidate(); }
/** * The <tt>NewStatusMessageDialog</tt> is the dialog containing the form for changing the status * message for a protocol provider. * * @author Yana Stamcheva * @author Adam Netocny */ public class NewStatusMessageDialog extends SIPCommDialog implements ActionListener, Skinnable { /** The Object used for logging. */ private final Logger logger = Logger.getLogger(NewStatusMessageDialog.class); /** The field, containing the status message. */ private final JTextField messageTextField = new JTextField(); /** The button, used to cancel this dialog. */ private final JButton cancelButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.CANCEL")); /** The presence operation set through which we change the status message. */ private final OperationSetPresence presenceOpSet; /** Message panel. */ private JPanel messagePanel; /** * Creates an instance of <tt>NewStatusMessageDialog</tt>. * * @param protocolProvider the <tt>ProtocolProviderService</tt>. */ public NewStatusMessageDialog(ProtocolProviderService protocolProvider) { presenceOpSet = (OperationSetPersistentPresence) protocolProvider.getOperationSet(OperationSetPresence.class); this.init(); pack(); } /** 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); } /** * Handles the <tt>ActionEvent</tt>. In order to change the status message with the new one calls * the <tt>PublishStatusMessageThread</tt>. * * @param e the event that notified us of the action */ public void actionPerformed(ActionEvent e) { JButton button = (JButton) e.getSource(); String name = button.getName(); if (name.equals("ok")) { new PublishStatusMessageThread(messageTextField.getText()).start(); } this.dispose(); } /** Requests the focus in the text field contained in this dialog. */ public void requestFocusInField() { this.messageTextField.requestFocus(); } /** This class allow to use a thread to change the presence status message. */ private class PublishStatusMessageThread extends Thread { private String message; private PresenceStatus currentStatus; public PublishStatusMessageThread(String message) { this.message = message; this.currentStatus = presenceOpSet.getPresenceStatus(); } public void run() { try { presenceOpSet.publishPresenceStatus(currentStatus, message); } catch (IllegalArgumentException e1) { logger.error("Error - changing status", e1); } catch (IllegalStateException e1) { logger.error("Error - changing status", e1); } catch (OperationFailedException e1) { if (e1.getErrorCode() == OperationFailedException.GENERAL_ERROR) { logger.error("General error occured while " + "publishing presence status.", e1); } else if (e1.getErrorCode() == OperationFailedException.NETWORK_FAILURE) { logger.error("Network failure occured while " + "publishing presence status.", e1); } else if (e1.getErrorCode() == OperationFailedException.PROVIDER_NOT_REGISTERED) { logger.error("Protocol provider must be" + "registered in order to change status.", e1); } } } } /** * Artificially clicks the cancel button when this panel is escaped. * * @param isEscaped indicates if this dialog is closed by the Esc shortcut */ protected void close(boolean isEscaped) { if (isEscaped) cancelButton.doClick(); } /** Reloads icon. */ public void loadSkin() { if (messagePanel != null) { for (Component component : messagePanel.getComponents()) { if (component instanceof ImageCanvas) { ImageCanvas cmp = (ImageCanvas) component; cmp.setImage(ImageLoader.getImage(ImageLoader.RENAME_DIALOG_ICON)); } } } } }
/** * The <tt>UnknownContactPanel</tt> replaces the contact list, when a <tt>SearchFilter</tt> founds * no matches. It is meant to propose the user some alternatives if she's looking for a contact, * which is not contained in the contact list. * * @author Yana Stamcheva * @author Adam Netocny */ public class UnknownContactPanel extends TransparentPanel implements TextFieldChangeListener, Skinnable { private final JButton addButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.ADD_CONTACT")); private final JButton callButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.CALL_CONTACT")); private JButton smsButton; private final JTextPane textArea = new JTextPane(); private final TransparentPanel buttonPanel = new TransparentPanel(new GridLayout(0, 1)); /** The main application window. */ private MainFrame parentWindow; /** An empty constructor allowing to extend this class. */ public UnknownContactPanel() {} /** * Creates the <tt>UnknownContactPanel</tt> by specifying the parent window. * * @param window the parent window */ public UnknownContactPanel(MainFrame window) { super(new BorderLayout()); this.parentWindow = window; TransparentPanel mainPanel = new TransparentPanel(new BorderLayout()); this.add(mainPanel, BorderLayout.NORTH); if (!ConfigurationUtils.isAddContactDisabled()) { initAddContactButton(); } initCallButton(); initSMSButton(); initTextArea(); mainPanel.add(textArea, BorderLayout.CENTER); if (callButton.getParent() != null) { textArea.setText( GuiActivator.getResources() .getI18NString( "service.gui.NO_CONTACTS_FOUND", new String[] {'"' + parentWindow.getCurrentSearchText() + '"'})); } else { textArea.setText( GuiActivator.getResources().getI18NString("service.gui.NO_CONTACTS_FOUND_SHORT")); } if (buttonPanel.getComponentCount() > 0) { TransparentPanel southPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER)); southPanel.add(buttonPanel); mainPanel.add(southPanel, BorderLayout.SOUTH); } loadSkin(); } private void initAddContactButton() { addButton.setAlignmentX(JButton.CENTER_ALIGNMENT); addButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.ADD_CONTACT")); buttonPanel.add(addButton); addButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { AddContactDialog dialog = new AddContactDialog(parentWindow); dialog.setContactAddress(parentWindow.getCurrentSearchText()); dialog.setVisible(true); } }); } /** Initializes the call button. */ private void initCallButton() { List<ProtocolProviderService> telephonyProviders = CallManager.getTelephonyProviders(); if (telephonyProviders != null && telephonyProviders.size() > 0) { if (callButton.getParent() != null) return; callButton.setAlignmentX(JButton.CENTER_ALIGNMENT); callButton.setMnemonic( GuiActivator.getResources().getI18nMnemonic("service.gui.CALL_CONTACT")); buttonPanel.add(callButton); callButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { String searchText = parentWindow.getCurrentSearchText(); if (searchText == null) return; CallManager.createCall(searchText, callButton); } }); } else { buttonPanel.remove(callButton); } } /** Initializes the call button. */ private void initSMSButton() { if (!parentWindow.hasOperationSet(OperationSetSmsMessaging.class)) return; smsButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.SEND_SMS")); smsButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.SMS_BUTTON_ICON")); buttonPanel.add(smsButton); smsButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final String searchText = parentWindow.getCurrentSearchText(); if (searchText == null) return; SMSManager.sendSMS(smsButton, searchText); } }); } /** Clicks the call contact button in order to call the unknown contact. */ public void startCall() { callButton.doClick(); } /** Clicks the add contact button in order to add the unknown contact to the contact list. */ public void addUnknownContact() { addButton.doClick(); } /** Invoked when any text is inserted in the search field. */ public void textInserted() { updateTextArea(parentWindow.getCurrentSearchText()); } /** Invoked when any text is removed from the search field. */ public void textRemoved() { updateTextArea(parentWindow.getCurrentSearchText()); } /** Creates the text area. */ private void initTextArea() { textArea.setOpaque(false); textArea.setEditable(false); StyledDocument doc = textArea.getStyledDocument(); MutableAttributeSet standard = new SimpleAttributeSet(); StyleConstants.setAlignment(standard, StyleConstants.ALIGN_CENTER); StyleConstants.setFontFamily(standard, textArea.getFont().getFamily()); StyleConstants.setFontSize(standard, 12); doc.setParagraphAttributes(0, 0, standard, true); parentWindow.addSearchFieldListener(this); } /** * Updates the text area to take into account the new search text. * * @param searchText the search text to update */ private void updateTextArea(String searchText) { if (callButton.getParent() != null) { textArea.setText( GuiActivator.getResources() .getI18NString( "service.gui.NO_CONTACTS_FOUND", new String[] {'"' + searchText + '"'})); this.revalidate(); this.repaint(); } } /** Reloads button resources. */ public void loadSkin() { addButton.setIcon( GuiActivator.getResources().getImage("service.gui.icons.ADD_CONTACT_16x16_ICON")); callButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.CALL_16x16_ICON")); if (smsButton != null) smsButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.SMS_BUTTON_ICON")); } /** * Updates the call button appearance and shows/hides this panel. * * @param isVisible indicates if this panel should be shown or hidden */ @Override public void setVisible(boolean isVisible) { if (isVisible) initCallButton(); super.setVisible(isVisible); } }
/** * Loads the tooltip with the data for current metacontact. * * @param tip the tooltip to fill. */ private void loadTooltip(final ExtendedTooltip tip) { Iterator<Contact> i = metaContact.getContacts(); ContactPhoneUtil contactPhoneUtil = ContactPhoneUtil.getPhoneUtil(metaContact); String statusMessage = null; Contact protocolContact; boolean isLoading = false; while (i.hasNext()) { protocolContact = i.next(); // Set the first found status message. if (statusMessage == null && protocolContact.getStatusMessage() != null && protocolContact.getStatusMessage().length() > 0) statusMessage = protocolContact.getStatusMessage(); if (ConfigurationUtils.isHideAccountStatusSelectorsEnabled()) break; ImageIcon protocolStatusIcon = ImageLoader.getIndexedProtocolIcon( ImageUtils.getBytesInImage(protocolContact.getPresenceStatus().getStatusIcon()), protocolContact.getProtocolProvider()); String contactAddress = protocolContact.getAddress(); // String statusMessage = protocolContact.getStatusMessage(); tip.addLine(protocolStatusIcon, contactAddress); addContactResourceTooltipLines(tip, protocolContact); if (!protocolContact.getProtocolProvider().isRegistered()) continue; contactPhoneUtil.addDetailsResponseListener( protocolContact, new OperationSetServerStoredContactInfo.DetailsResponseListener() { public void detailsRetrieved(final Iterator<GenericDetail> details) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater( new Runnable() { public void run() { detailsRetrieved(details); } }); return; } // remove previously shown information // as it contains "Loading..." text tip.removeAllLines(); // load it again loadTooltip(tip); } }); List<String> phones = contactPhoneUtil.getPhones(protocolContact); if (phones != null) { addPhoneTooltipLines(tip, phones.iterator()); } else isLoading = true; } if (isLoading) tip.addLine(null, GuiActivator.getResources().getI18NString("service.gui.LOADING")); if (statusMessage != null) tip.setBottomText(statusMessage); }
/** Creates a file conversation component. */ public FileTransferConversationComponent() { imageLabel = new FileImageLabel(); constraints.gridx = 0; constraints.gridy = 0; constraints.gridwidth = 1; constraints.gridheight = 4; constraints.anchor = GridBagConstraints.NORTHWEST; constraints.insets = new Insets(5, 5, 5, 5); add(imageLabel, constraints); imageLabel.setIcon(new ImageIcon(ImageLoader.getImage(ImageLoader.DEFAULT_FILE_ICON))); constraints.gridx = 1; constraints.gridy = 0; constraints.gridwidth = 3; constraints.gridheight = 1; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.weightx = 1.0; constraints.anchor = GridBagConstraints.NORTHWEST; constraints.insets = new Insets(5, 5, 5, 5); add(titleLabel, constraints); titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 11f)); constraints.gridx = 1; constraints.gridy = 1; constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(0, 5, 5, 5); add(fileLabel, constraints); constraints.gridx = 1; constraints.gridy = 2; constraints.gridwidth = 1; constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(0, 5, 0, 5); constraints.fill = GridBagConstraints.NONE; add(errorIconLabel, constraints); errorIconLabel.setVisible(false); constraints.gridx = 2; constraints.gridy = 2; constraints.gridwidth = 2; constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(0, 5, 0, 5); constraints.fill = GridBagConstraints.HORIZONTAL; add(errorArea, constraints); errorArea.setForeground(new Color(resources.getColor("service.gui.ERROR_FOREGROUND"))); setTextAreaStyle(errorArea); errorArea.setVisible(false); constraints.gridx = 1; constraints.gridy = 3; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0.0; constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(0, 5, 0, 5); add(retryButton, constraints); retryButton.setText(GuiActivator.getResources().getI18NString("service.gui.RETRY")); retryButton.setVisible(false); constraints.gridx = 1; constraints.gridy = 3; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0.0; constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(0, 5, 0, 5); add(cancelButton, constraints); cancelButton.setText(GuiActivator.getResources().getI18NString("service.gui.CANCEL")); cancelButton.addActionListener(this); cancelButton.setVisible(false); constraints.gridx = 2; constraints.gridy = 3; constraints.gridwidth = GridBagConstraints.RELATIVE; constraints.gridheight = 1; constraints.weightx = 0.0; constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.EAST; constraints.insets = new Insets(0, 5, 0, 5); constraints.gridx = 3; constraints.gridy = 3; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0.0; constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.LINE_END; constraints.insets = new Insets(0, 5, 0, 5); add(progressPropertiesPanel, constraints); estimatedTimeLabel.setFont(estimatedTimeLabel.getFont().deriveFont(11f)); estimatedTimeLabel.setVisible(false); progressSpeedLabel.setFont(progressSpeedLabel.getFont().deriveFont(11f)); progressSpeedLabel.setVisible(false); progressPropertiesPanel.add(progressSpeedLabel); progressPropertiesPanel.add(estimatedTimeLabel); constraints.gridx = 1; constraints.gridy = 3; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0.0; constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(0, 5, 0, 5); constraints.fill = GridBagConstraints.NONE; add(acceptButton, constraints); acceptButton.setText(GuiActivator.getResources().getI18NString("service.gui.ACCEPT")); acceptButton.setVisible(false); constraints.gridx = 2; constraints.gridy = 3; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0.0; constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(0, 5, 0, 5); constraints.fill = GridBagConstraints.NONE; add(rejectButton, constraints); rejectButton.setText(GuiActivator.getResources().getI18NString("service.gui.REJECT")); rejectButton.setVisible(false); constraints.gridx = 1; constraints.gridy = 3; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0.0; constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(0, 5, 0, 5); constraints.fill = GridBagConstraints.NONE; add(openFileButton, constraints); openFileButton.setText(GuiActivator.getResources().getI18NString("service.gui.OPEN")); openFileButton.setVisible(false); openFileButton.addActionListener(this); constraints.gridx = 2; constraints.gridy = 3; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0.0; constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(0, 5, 0, 5); constraints.fill = GridBagConstraints.NONE; add(openFolderButton, constraints); openFolderButton.setText(GuiActivator.getResources().getI18NString("service.gui.OPEN_FOLDER")); openFolderButton.setVisible(false); openFolderButton.addActionListener(this); constraints.gridx = 1; constraints.gridy = 2; constraints.gridwidth = 3; constraints.gridheight = 1; constraints.weightx = 1.0; constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(0, 5, 0, 5); constraints.ipadx = 150; constraints.fill = GridBagConstraints.HORIZONTAL; add(progressBar, constraints); progressBar.setVisible(false); progressBar.setStringPainted(true); }
@Override public void run() { try { presence.publishPresenceStatus(status, ""); } catch (IllegalArgumentException e1) { logger.error("Error - changing status", e1); } catch (IllegalStateException e1) { logger.error("Error - changing status", e1); } catch (OperationFailedException e1) { if (e1.getErrorCode() == OperationFailedException.GENERAL_ERROR) { String msgText = GuiActivator.getResources() .getI18NString( "service.gui.STATUS_CHANGE_GENERAL_ERROR", new String[] { protocolProvider.getAccountID().getUserID(), protocolProvider.getAccountID().getService() }); new ErrorDialog( null, GuiActivator.getResources().getI18NString("service.gui.GENERAL_ERROR"), msgText, e1) .showDialog(); } else if (e1.getErrorCode() == OperationFailedException.NETWORK_FAILURE) { String msgText = GuiActivator.getResources() .getI18NString( "service.gui.STATUS_CHANGE_NETWORK_FAILURE", new String[] { protocolProvider.getAccountID().getUserID(), protocolProvider.getAccountID().getService() }); new ErrorDialog( null, msgText, GuiActivator.getResources().getI18NString("service.gui.NETWORK_FAILURE"), e1) .showDialog(); } else if (e1.getErrorCode() == OperationFailedException.PROVIDER_NOT_REGISTERED) { String msgText = GuiActivator.getResources() .getI18NString( "service.gui.STATUS_CHANGE_NETWORK_FAILURE", new String[] { protocolProvider.getAccountID().getUserID(), protocolProvider.getAccountID().getService() }); new ErrorDialog( null, GuiActivator.getResources().getI18NString("service.gui.NETWORK_FAILURE"), msgText, e1) .showDialog(); } logger.error("Error - changing status", e1); } }
/** * Returns this panel that has been configured to display the meta contact and meta contact group * cells. * * @param tree the source tree * @param value the tree node * @param selected indicates if the node is selected * @param expanded indicates if the node is expanded * @param leaf indicates if the node is a leaf * @param row indicates the row number of the node * @param hasFocus indicates if the node has the focus * @return this panel */ public Component getTreeCellRendererComponent( JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { this.treeContactList = (TreeContactList) tree; this.row = row; this.isSelected = selected; this.treeNode = (TreeNode) value; this.rightLabel.setIcon(null); DefaultTreeContactList contactList = (DefaultTreeContactList) tree; setBorder(); addLabels(1); // Set background color. if (contactList instanceof TreeContactList) { ContactListFilter filter = ((TreeContactList) contactList).getCurrentFilter(); if (filter != null && filter.equals(TreeContactList.historyFilter) && value instanceof ContactNode && row % 2 == 0) { setBackground(Constants.CALL_HISTORY_EVEN_ROW_COLOR); } else { setBackground(Color.WHITE); } } // Make appropriate adjustments for contact nodes and group nodes. if (value instanceof ContactNode) { UIContactImpl contact = ((ContactNode) value).getContactDescriptor(); String displayName = contact.getDisplayName(); if ((displayName == null || displayName.trim().length() < 1) && !(contact instanceof ShowMoreContact)) { displayName = GuiActivator.getResources().getI18NString("service.gui.UNKNOWN"); } this.nameLabel.setText(displayName); if (statusIcon != null && contactList.isContactActive(contact) && statusIcon instanceof ImageIcon) ((ImageIcon) statusIcon).setImage(msgReceivedImage); else statusIcon = contact.getStatusIcon(); this.statusLabel.setIcon(statusIcon); this.nameLabel.setFont(this.getFont().deriveFont(Font.PLAIN)); if (contactForegroundColor != null) nameLabel.setForeground(contactForegroundColor); // Initializes status message components if the given meta contact // contains a status message. this.initDisplayDetails(contact.getDisplayDetails()); if (this.treeContactList.isContactButtonsVisible()) this.initButtonsPanel(contact); int avatarWidth, avatarHeight; if (isSelected && treeContactList.isContactButtonsVisible()) { avatarWidth = EXTENDED_AVATAR_WIDTH; avatarHeight = EXTENDED_AVATAR_HEIGHT; } else { avatarWidth = AVATAR_WIDTH; avatarHeight = AVATAR_HEIGHT; } Icon avatar = contact.getAvatar(isSelected, avatarWidth, avatarHeight); if (avatar != null) { this.rightLabel.setIcon(avatar); } if (contact instanceof ShowMoreContact) { rightLabel.setFont(rightLabel.getFont().deriveFont(12f)); rightLabel.setForeground(Color.GRAY); rightLabel.setText((String) contact.getDescriptor()); } else { rightLabel.setFont(rightLabel.getFont().deriveFont(9f)); rightLabel.setText(""); } this.setToolTipText(contact.getDescriptor().toString()); } else if (value instanceof GroupNode) { UIGroupImpl groupItem = ((GroupNode) value).getGroupDescriptor(); this.nameLabel.setText(groupItem.getDisplayName()); this.nameLabel.setFont(this.getFont().deriveFont(Font.BOLD)); if (groupForegroundColor != null) this.nameLabel.setForeground(groupForegroundColor); this.remove(displayDetailsLabel); this.remove(callButton); this.remove(callVideoButton); this.remove(desktopSharingButton); this.remove(chatButton); this.remove(addContactButton); clearCustomActionButtons(); statusIcon = expanded ? openedGroupIcon : closedGroupIcon; this.statusLabel.setIcon(expanded ? openedGroupIcon : closedGroupIcon); // We have no photo icon for groups. this.rightLabel.setIcon(null); this.rightLabel.setText(""); if (groupItem.countChildContacts() >= 0) { rightLabel.setFont(rightLabel.getFont().deriveFont(9f)); this.rightLabel.setForeground(Color.BLACK); this.rightLabel.setText( groupItem.countOnlineChildContacts() + "/" + groupItem.countChildContacts()); } this.initDisplayDetails(groupItem.getDisplayDetails()); this.initButtonsPanel(groupItem); this.setToolTipText(groupItem.getDescriptor().toString()); } return this; }
/** * 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)); }
/** 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); }