/** Constructs the <tt>AuthenticationWindow</tt>. */ private void init() { this.idValue = new JTextField( chatRoom.getParentProvider().getProtocolProvider().getAccountID().getUserID()); this.infoTextArea.setOpaque(false); this.infoTextArea.setLineWrap(true); this.infoTextArea.setWrapStyleWord(true); this.infoTextArea.setFont(infoTextArea.getFont().deriveFont(Font.BOLD)); this.infoTextArea.setEditable(false); this.infoTextArea.setText( GuiActivator.getResources() .getI18NString( "service.gui.CHAT_ROOM_REQUIRES_PASSWORD", new String[] {chatRoom.getChatRoomName()})); this.idLabel.setFont(idLabel.getFont().deriveFont(Font.BOLD)); this.passwdLabel.setFont(passwdLabel.getFont().deriveFont(Font.BOLD)); this.labelsPanel.add(idLabel); this.labelsPanel.add(passwdLabel); this.textFieldsPanel.add(idValue); this.textFieldsPanel.add(passwdField); this.buttonsPanel.add(loginButton); this.buttonsPanel.add(cancelButton); this.mainPanel.add(infoTextArea, BorderLayout.NORTH); this.mainPanel.add(labelsPanel, BorderLayout.WEST); this.mainPanel.add(textFieldsPanel, BorderLayout.CENTER); this.mainPanel.add(buttonsPanel, BorderLayout.SOUTH); this.backgroundPanel.add(mainPanel, BorderLayout.CENTER); this.loginButton.setName("ok"); this.cancelButton.setName("cancel"); this.loginButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.OK")); this.cancelButton.setMnemonic( GuiActivator.getResources().getI18nMnemonic("service.gui.CANCEL")); this.loginButton.addActionListener(this); this.cancelButton.addActionListener(this); this.getRootPane().setDefaultButton(loginButton); this.setTransparent(true); }
/** Removes the room that is currently selected. */ void removeSelectedRoom() { ChatRoomWrapper chatRoomWrapper = chatRoomsTableModel.getValueAt(chatRoomList.getSelectedRow()); ConferenceChatManager conferenceManager = GuiActivator.getUIService().getConferenceChatManager(); conferenceManager.removeChatRoom(chatRoomWrapper); }
/** * Creates an instance of the <tt>LoginWindow</tt>. * * @param chatRoom the chat room for which we're authenticating */ public ChatRoomAuthenticationWindow(ChatRoomWrapper chatRoom) { this.chatRoom = chatRoom; ImageIcon logoImage = new ImageIcon(chatRoom.getParentProvider().getImage()); backgroundPanel = new LoginWindowBackground(logoImage); this.backgroundPanel.setPreferredSize(new Dimension(420, 230)); this.backgroundPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); this.backgroundPanel.setBorder(BorderFactory.createEmptyBorder(20, 5, 5, 5)); this.getContentPane().setLayout(new BorderLayout()); this.init(); this.getContentPane().add(backgroundPanel, BorderLayout.CENTER); this.setResizable(false); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); this.setTitle( GuiActivator.getResources() .getI18NString( "service.gui.AUTHENTICATION_WINDOW_TITLE", new String[] {chatRoom.getParentProvider().getName()})); this.enableKeyActions(); }
/** Opens the currently selected chat. */ void openChatForSelection() { Object selectedValue = this.chatRoomsTableModel.getValueAt(this.chatRoomList.getSelectedRow()); ChatRoomWrapper chatRoomWrapper; if (selectedValue instanceof ChatRoomWrapper) chatRoomWrapper = (ChatRoomWrapper) selectedValue; else return; if (!chatRoomWrapper.getChatRoom().isJoined()) { GuiActivator.getUIService().getConferenceChatManager().joinChatRoom(chatRoomWrapper); } ChatWindowManager chatWindowManager = GuiActivator.getUIService().getChatWindowManager(); ChatPanel chatPanel = chatWindowManager.getMultiChat(chatRoomWrapper, true); chatWindowManager.openChat(chatPanel, true); }
private String getNickname() { String nickName = null; ChatOperationReasonDialog reasonDialog = new ChatOperationReasonDialog( GuiActivator.getResources().getI18NString("service.gui.CHANGE_NICKNAME"), GuiActivator.getResources().getI18NString("service.gui.CHANGE_NICKNAME_LABEL")); reasonDialog.setReasonFieldText(""); int result = reasonDialog.showDialog(); if (result == MessageDialog.OK_RETURN_CODE) { nickName = reasonDialog.getReason().trim(); } return nickName; }
/** * Handles the <tt>ActionEvent</tt>, when one of the tool bar buttons is clicked. * * @param e the <tt>ActionEvent</tt> that notified us */ public void actionPerformed(ActionEvent e) { AbstractButton button = (AbstractButton) e.getSource(); String buttonText = button.getName(); ChatPanel chatPanel = chatContainer.getCurrentChat(); if (buttonText.equals("previous")) { chatPanel.loadPreviousPageFromHistory(); } else if (buttonText.equals("next")) { chatPanel.loadNextPageFromHistory(); } else if (buttonText.equals("sendFile")) { SipCommFileChooser scfc = GenericFileDialog.create( null, "Send file...", SipCommFileChooser.LOAD_FILE_OPERATION, ConfigurationUtils.getSendFileLastDir()); File selectedFile = scfc.getFileFromDialog(); if (selectedFile != null) { ConfigurationUtils.setSendFileLastDir(selectedFile.getParent()); chatContainer.getCurrentChat().sendFile(selectedFile); } } else if (buttonText.equals("invite")) { ChatInviteDialog inviteDialog = new ChatInviteDialog(chatPanel); inviteDialog.setVisible(true); } else if (buttonText.equals("leave")) { ChatRoomWrapper chatRoomWrapper = (ChatRoomWrapper) chatPanel.getChatSession().getDescriptor(); ChatRoomWrapper leavedRoomWrapped = GuiActivator.getMUCService().leaveChatRoom(chatRoomWrapper); } else if (buttonText.equals("call")) { call(false, false); } else if (buttonText.equals("callVideo")) { call(true, false); } else if (buttonText.equals("desktop")) { call(true, true); } else if (buttonText.equals("options")) { GuiActivator.getUIService().getConfigurationContainer().setVisible(true); } else if (buttonText.equals("font")) chatPanel.showFontChooserDialog(); else if (buttonText.equals("createConference")) { chatPanel.showChatConferenceDialog(); } }
/** * Handles the <tt>ActionEvent</tt>. Determines which menu item was selected and makes the * appropriate operations. * * @param e the event. */ public void actionPerformed(ActionEvent e) { JMenuItem menuItem = (JMenuItem) e.getSource(); String itemName = menuItem.getName(); ConferenceChatManager conferenceManager = GuiActivator.getUIService().getConferenceChatManager(); if (itemName.equals("removeChatRoom")) { conferenceManager.removeChatRoom(chatRoomWrapper); } else if (itemName.equals("leaveChatRoom")) { conferenceManager.leaveChatRoom(chatRoomWrapper); } else if (itemName.equals("joinChatRoom")) { conferenceManager.joinChatRoom(chatRoomWrapper); } else if (itemName.equals("openChatRoom")) { if (chatRoomWrapper.getChatRoom() != null) { if (!chatRoomWrapper.getChatRoom().isJoined()) { conferenceManager.joinChatRoom(chatRoomWrapper); } } else { // this is not a server persistent room we must create it // and join chatRoomWrapper = GuiActivator.getUIService() .getConferenceChatManager() .createChatRoom( chatRoomWrapper.getChatRoomName(), chatRoomWrapper.getParentProvider().getProtocolProvider(), new ArrayList<String>(), "", true, true); } ChatWindowManager chatWindowManager = GuiActivator.getUIService().getChatWindowManager(); ChatPanel chatPanel = chatWindowManager.getMultiChat(chatRoomWrapper, true); chatWindowManager.openChat(chatPanel, true); } else if (itemName.equals("joinAsChatRoom")) { ChatRoomAuthenticationWindow authWindow = new ChatRoomAuthenticationWindow(chatRoomWrapper); authWindow.setVisible(true); } }
/** 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")); } }
/** * Handles the <tt>ActionEvent</tt> triggered when one of the buttons is clicked. When "Login" * button is choosen installs a new account from the user input and logs in. * * @param evt the action event that has just occurred. */ public void actionPerformed(ActionEvent evt) { JButton button = (JButton) evt.getSource(); String buttonName = button.getName(); if (buttonName.equals("ok")) { GuiActivator.getUIService() .getConferenceChatManager() .joinChatRoom( chatRoom, idValue.getText(), new String(passwdField.getPassword()).getBytes()); } this.dispose(); }
/** * Establishes a call. * * @param isVideo indicates if a video call should be established. * @param isDesktopSharing indicates if a desktopSharing should be established. */ private void call(boolean isVideo, boolean isDesktopSharing) { ChatPanel chatPanel = chatContainer.getCurrentChat(); ChatSession chatSession = chatPanel.getChatSession(); Class<? extends OperationSet> opSetClass; if (isVideo) { if (isDesktopSharing) opSetClass = OperationSetDesktopSharingServer.class; else opSetClass = OperationSetVideoTelephony.class; } else opSetClass = OperationSetBasicTelephony.class; List<ChatTransport> telTransports = null; if (chatSession != null) telTransports = chatSession.getTransportsForOperationSet(opSetClass); List<ChatTransport> contactOpSetSupported; contactOpSetSupported = getOperationSetForCapabilities(telTransports, opSetClass); List<UIContactDetail> res = new ArrayList<UIContactDetail>(); for (ChatTransport ct : contactOpSetSupported) { HashMap<Class<? extends OperationSet>, ProtocolProviderService> m = new HashMap<Class<? extends OperationSet>, ProtocolProviderService>(); m.put(opSetClass, ct.getProtocolProvider()); UIContactDetailImpl d = new UIContactDetailImpl( ct.getName(), ct.getDisplayName(), null, null, null, m, null, ct.getName()); PresenceStatus status = ct.getStatus(); byte[] statusIconBytes = status.getStatusIcon(); if (statusIconBytes != null && statusIconBytes.length > 0) { d.setStatusIcon( new ImageIcon( ImageLoader.getIndexedProtocolImage( ImageUtils.getBytesInImage(statusIconBytes), ct.getProtocolProvider()))); } res.add(d); } Point location = new Point(callButton.getX(), callButton.getY() + callButton.getHeight()); SwingUtilities.convertPointToScreen(location, this); MetaContact metaContact = GuiActivator.getUIService().getChatContact(chatPanel); UIContactImpl uiContact = null; if (metaContact != null) uiContact = MetaContactListSource.getUIContact(metaContact); CallManager.call(res, uiContact, isVideo, isDesktopSharing, callButton, location); }
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); }
/** * Creates a new <tt>JMenuItem</tt> and adds it to this <tt>JPopupMenu</tt>. * * @param textKey the key of the internationalized string in the resources of the application * which represents the text of the new <tt>JMenuItem</tt> * @param iconID the <tt>ImageID</tt> of the image in the resources of the application which * represents the icon of the new <tt>JMenuItem</tt> * @param name the name of the new <tt>JMenuItem</tt> * @return a new <tt>JMenuItem</tt> instance which has been added to this <tt>JPopupMenu</tt> */ private JMenuItem createMenuItem(String textKey, ImageID iconID, String name) { ResourceManagementService resources = GuiActivator.getResources(); JMenuItem menuItem = new JMenuItem( resources.getI18NString(textKey), new ImageIcon(ImageLoader.getImage(iconID))); menuItem.setMnemonic(resources.getI18nMnemonic(textKey)); menuItem.setName(name); menuItem.addActionListener(this); add(menuItem); return menuItem; }
/** * Implements ChatChangeListener#chatChanged(ChatPanel). * * @param chatPanel the <tt>ChatPanel</tt>, which changed */ public void chatChanged(ChatPanel chatPanel) { if (chatPanel == null) { setChatSession(null); } else { MetaContact contact = GuiActivator.getUIService().getChatContact(chatPanel); for (PluginComponent c : pluginContainer.getPluginComponents()) c.setCurrentContact(contact); ChatSession chatSession = chatPanel.getChatSession(); setChatSession(chatSession); leaveChatRoomButton.setEnabled(chatSession instanceof ConferenceChatSession); desktopSharingButton.setEnabled(!(chatSession instanceof ConferenceChatSession)); inviteButton.setEnabled(chatPanel.findInviteChatTransport() != null); sendFileButton.setEnabled(chatPanel.findFileTransferChatTransport() != null); inviteButton.setEnabled(!chatPanel.isPrivateMessagingChat()); if (chatSession instanceof ConferenceChatSession) { updateInviteContactButton(); callButton.setVisible(false); callVideoButton.setVisible(false); callButton.setEnabled(true); callVideoButton.setEnabled(true); } else if (contact != null) { callButton.setVisible(true); callVideoButton.setVisible(true); new UpdateCallButtonWorker(contact).start(); } changeHistoryButtonsState(chatPanel); setCallButtonsName(); setCallButtonsIcons(); currentChatTransportChanged(chatSession); } }
/** * Implements ChatChangeListener#chatChanged(ChatPanel). * * @param chatPanel the <tt>ChatPanel</tt>, which changed */ public void chatChanged(ChatPanel chatPanel) { if (chatPanel == null) { setChatSession(null); } else { MetaContact contact = GuiActivator.getUIService().getChatContact(chatPanel); for (PluginComponent c : pluginContainer.getPluginComponents()) c.setCurrentContact(contact); setChatSession(chatPanel.chatSession); leaveChatRoomButton.setEnabled(chatPanel.chatSession instanceof ConferenceChatSession); inviteButton.setEnabled(chatPanel.findInviteChatTransport() != null); sendFileButton.setEnabled(chatPanel.findFileTransferChatTransport() != null); new UpdateCallButtonWorker(contact).start(); changeHistoryButtonsState(chatPanel); } }
/** Initializes the chat rooms list interface. */ private void initChatRoomList() { this.chatRoomsTableModel = new ChatRoomTableModel(chatRoomList); this.chatRoomList.addMouseListener(this); this.chatRoomList.setDefaultRenderer( ProtocolProviderService.class, new ProtocolProviderTableCellRenderer()); this.chatRoomList.setDefaultRenderer(ChatRoomWrapper.class, new ChatRoomTableCellRenderer()); this.chatRoomList.setOpaque(false); this.chatRoomList.setModel(chatRoomsTableModel); ConferenceChatManager confChatManager = GuiActivator.getUIService().getConferenceChatManager(); confChatManager.addChatRoomListChangeListener(chatRoomsTableModel); // this.chatRoomList.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); // this.chatRoomList.getColumnModel().getColumn(0).setMinWidth(250); // this.chatRoomList.getColumnModel().getColumn(1).setMinWidth(250); // this.chatRoomList.getColumnModel().getColumn(2).setPreferredWidth(50); }
/** * The <tt>ChatRoomAuthenticationWindow</tt> is the the authentication window for chat rooms that * require password. * * @author Yana Stamcheva * @author Adam Netocny */ public class ChatRoomAuthenticationWindow extends SIPCommFrame implements ActionListener, Skinnable { private JTextArea infoTextArea = new JTextArea(); private JLabel idLabel = new JLabel(GuiActivator.getResources().getI18NString("service.gui.IDENTIFIER")); private JLabel passwdLabel = new JLabel(GuiActivator.getResources().getI18NString("service.gui.PASSWORD")); private JTextField idValue; private JPasswordField passwdField = new JPasswordField(15); private JButton loginButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.OK")); private JButton cancelButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.CANCEL")); private JPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1, 8, 8)); private JPanel textFieldsPanel = new TransparentPanel(new GridLayout(0, 1, 8, 8)); private JPanel mainPanel = new TransparentPanel(new BorderLayout(10, 10)); private JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER)); private LoginWindowBackground backgroundPanel; private ChatRoomWrapper chatRoom; /** * Creates an instance of the <tt>LoginWindow</tt>. * * @param chatRoom the chat room for which we're authenticating */ public ChatRoomAuthenticationWindow(ChatRoomWrapper chatRoom) { this.chatRoom = chatRoom; ImageIcon logoImage = new ImageIcon(chatRoom.getParentProvider().getImage()); backgroundPanel = new LoginWindowBackground(logoImage); this.backgroundPanel.setPreferredSize(new Dimension(420, 230)); this.backgroundPanel.setLayout(new FlowLayout(FlowLayout.RIGHT)); this.backgroundPanel.setBorder(BorderFactory.createEmptyBorder(20, 5, 5, 5)); this.getContentPane().setLayout(new BorderLayout()); this.init(); this.getContentPane().add(backgroundPanel, BorderLayout.CENTER); this.setResizable(false); this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); this.setTitle( GuiActivator.getResources() .getI18NString( "service.gui.AUTHENTICATION_WINDOW_TITLE", new String[] {chatRoom.getParentProvider().getName()})); this.enableKeyActions(); } /** Constructs the <tt>AuthenticationWindow</tt>. */ private void init() { this.idValue = new JTextField( chatRoom.getParentProvider().getProtocolProvider().getAccountID().getUserID()); this.infoTextArea.setOpaque(false); this.infoTextArea.setLineWrap(true); this.infoTextArea.setWrapStyleWord(true); this.infoTextArea.setFont(infoTextArea.getFont().deriveFont(Font.BOLD)); this.infoTextArea.setEditable(false); this.infoTextArea.setText( GuiActivator.getResources() .getI18NString( "service.gui.CHAT_ROOM_REQUIRES_PASSWORD", new String[] {chatRoom.getChatRoomName()})); this.idLabel.setFont(idLabel.getFont().deriveFont(Font.BOLD)); this.passwdLabel.setFont(passwdLabel.getFont().deriveFont(Font.BOLD)); this.labelsPanel.add(idLabel); this.labelsPanel.add(passwdLabel); this.textFieldsPanel.add(idValue); this.textFieldsPanel.add(passwdField); this.buttonsPanel.add(loginButton); this.buttonsPanel.add(cancelButton); this.mainPanel.add(infoTextArea, BorderLayout.NORTH); this.mainPanel.add(labelsPanel, BorderLayout.WEST); this.mainPanel.add(textFieldsPanel, BorderLayout.CENTER); this.mainPanel.add(buttonsPanel, BorderLayout.SOUTH); this.backgroundPanel.add(mainPanel, BorderLayout.CENTER); this.loginButton.setName("ok"); this.cancelButton.setName("cancel"); this.loginButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.OK")); this.cancelButton.setMnemonic( GuiActivator.getResources().getI18nMnemonic("service.gui.CANCEL")); this.loginButton.addActionListener(this); this.cancelButton.addActionListener(this); this.getRootPane().setDefaultButton(loginButton); this.setTransparent(true); } /** * Sets transparent background to all components in the login window, because of the nonwhite * background. * * @param transparent <code>true</code> to set a transparent background, <code>false</code> * otherwise. */ private void setTransparent(boolean transparent) { this.mainPanel.setOpaque(!transparent); this.labelsPanel.setOpaque(!transparent); this.textFieldsPanel.setOpaque(!transparent); this.buttonsPanel.setOpaque(!transparent); } /** * Handles the <tt>ActionEvent</tt> triggered when one of the buttons is clicked. When "Login" * button is choosen installs a new account from the user input and logs in. * * @param evt the action event that has just occurred. */ public void actionPerformed(ActionEvent evt) { JButton button = (JButton) evt.getSource(); String buttonName = button.getName(); if (buttonName.equals("ok")) { GuiActivator.getUIService() .getConferenceChatManager() .joinChatRoom( chatRoom, idValue.getText(), new String(passwdField.getPassword()).getBytes()); } this.dispose(); } /** * The <tt>LoginWindowBackground</tt> is a <tt>JPanel</tt> that overrides the <code>paintComponent * </code> method to provide a custom background image for this window. */ private static class LoginWindowBackground extends JPanel { private ImageIcon bgImage; public LoginWindowBackground(ImageIcon bgImage) { this.bgImage = bgImage; } /** * Sets background image. * * @param bgImage Background image. */ public void setBgImage(ImageIcon bgImage) { this.bgImage = bgImage; } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); g = g.create(); try { AntialiasingManager.activateAntialiasing(g); Graphics2D g2 = (Graphics2D) g; if (bgImage != null) g2.drawImage(bgImage.getImage(), 30, 30, null); g2.drawImage( ImageLoader.getImage(ImageLoader.AUTH_WINDOW_BACKGROUND), 0, 0, this.getWidth(), this.getHeight(), null); } finally { g.dispose(); } } } /** Enables the actions when a key is pressed, for now closes the window when esc is pressed. */ private void enableKeyActions() { UIAction act = new UIAction() { public void actionPerformed(ActionEvent e) { ChatRoomAuthenticationWindow.this.setVisible(false); } }; getRootPane().getActionMap().put("close", act); InputMap imap = this.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close"); } @Override protected void close(boolean isEscaped) { this.cancelButton.doClick(); } /** * Shows this modal dialog. * * @param isVisible specifies whether we should be showing or hiding the window. */ @Override public void setVisible(boolean isVisible) { this.pack(); super.setVisible(isVisible); if (isVisible) { this.passwdField.requestFocus(); } } /** Reloads logo image. */ public void loadSkin() { ImageIcon logoImage = new ImageIcon(chatRoom.getParentProvider().getImage()); backgroundPanel.setBgImage(logoImage); } }
/** * Handles the <tt>ActionEvent</tt>, when one of the tool bar buttons is clicked. * * @param e the <tt>ActionEvent</tt> that notified us */ public void actionPerformed(ActionEvent e) { AbstractButton button = (AbstractButton) e.getSource(); String buttonText = button.getName(); ChatPanel chatPanel = chatContainer.getCurrentChat(); if (buttonText.equals("previous")) { chatPanel.loadPreviousPageFromHistory(); } else if (buttonText.equals("next")) { chatPanel.loadNextPageFromHistory(); } else if (buttonText.equals("sendFile")) { SipCommFileChooser scfc = GenericFileDialog.create( null, "Send file...", SipCommFileChooser.LOAD_FILE_OPERATION, ConfigurationUtils.getSendFileLastDir()); File selectedFile = scfc.getFileFromDialog(); if (selectedFile != null) { ConfigurationUtils.setSendFileLastDir(selectedFile.getParent()); chatContainer.getCurrentChat().sendFile(selectedFile); } } else if (buttonText.equals("history")) { HistoryWindow history; HistoryWindowManager historyWindowManager = GuiActivator.getUIService().getHistoryWindowManager(); ChatSession chatSession = chatPanel.getChatSession(); if (historyWindowManager.containsHistoryWindowForContact(chatSession.getDescriptor())) { history = historyWindowManager.getHistoryWindowForContact(chatSession.getDescriptor()); if (history.getState() == JFrame.ICONIFIED) history.setState(JFrame.NORMAL); history.toFront(); } else { history = new HistoryWindow(chatPanel.getChatSession().getDescriptor()); history.setVisible(true); historyWindowManager.addHistoryWindowForContact(chatSession.getDescriptor(), history); } } else if (buttonText.equals("invite")) { ChatInviteDialog inviteDialog = new ChatInviteDialog(chatPanel); inviteDialog.setVisible(true); } else if (buttonText.equals("leave")) { ConferenceChatManager conferenceManager = GuiActivator.getUIService().getConferenceChatManager(); conferenceManager.leaveChatRoom((ChatRoomWrapper) chatPanel.getChatSession().getDescriptor()); } else if (buttonText.equals("call")) { call(false, false); } else if (buttonText.equals("callVideo")) { call(true, false); } else if (buttonText.equals("desktop")) { call(true, true); } else if (buttonText.equals("options")) { GuiActivator.getUIService().getConfigurationContainer().setVisible(true); } else if (buttonText.equals("font")) chatPanel.showFontChooserDialog(); }
/** 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); }
/** * Handles the <tt>ActionEvent</tt>. Determines which menu item was selected and makes the * appropriate operations. * * @param e the event. */ public void actionPerformed(ActionEvent e) { JMenuItem menuItem = (JMenuItem) e.getSource(); String itemName = menuItem.getName(); ConferenceChatManager conferenceManager = GuiActivator.getUIService().getConferenceChatManager(); if (itemName.equals("removeChatRoom")) { conferenceManager.removeChatRoom(chatRoomWrapper); } else if (itemName.equals("leaveChatRoom")) { conferenceManager.leaveChatRoom(chatRoomWrapper); } else if (itemName.equals("joinChatRoom")) { String nickName = null; nickName = ConfigurationManager.getChatRoomProperty( chatRoomWrapper.getParentProvider().getProtocolProvider(), chatRoomWrapper.getChatRoomID(), "userNickName"); if (nickName == null) nickName = getNickname(); if (nickName != null) conferenceManager.joinChatRoom(chatRoomWrapper, nickName, null); else conferenceManager.joinChatRoom(chatRoomWrapper); } else if (itemName.equals("openChatRoom")) { if (chatRoomWrapper.getChatRoom() != null) { if (!chatRoomWrapper.getChatRoom().isJoined()) { String nickName = null; nickName = ConfigurationManager.getChatRoomProperty( chatRoomWrapper.getParentProvider().getProtocolProvider(), chatRoomWrapper.getChatRoomID(), "userNickName"); if (nickName == null) nickName = getNickname(); if (nickName != null) conferenceManager.joinChatRoom(chatRoomWrapper, nickName, null); else conferenceManager.joinChatRoom(chatRoomWrapper); } } else { // this is not a server persistent room we must create it // and join chatRoomWrapper = GuiActivator.getUIService() .getConferenceChatManager() .createChatRoom( chatRoomWrapper.getChatRoomName(), chatRoomWrapper.getParentProvider().getProtocolProvider(), new ArrayList<String>(), "", false, true); String nickName = null; nickName = ConfigurationManager.getChatRoomProperty( chatRoomWrapper.getParentProvider().getProtocolProvider(), chatRoomWrapper.getChatRoomID(), "userNickName"); if (nickName == null) nickName = getNickname(); if (nickName != null) conferenceManager.joinChatRoom(chatRoomWrapper, nickName, null); else conferenceManager.joinChatRoom(chatRoomWrapper); } ChatWindowManager chatWindowManager = GuiActivator.getUIService().getChatWindowManager(); ChatPanel chatPanel = chatWindowManager.getMultiChat(chatRoomWrapper, true); chatWindowManager.openChat(chatPanel, true); } else if (itemName.equals("joinAsChatRoom")) { ChatRoomAuthenticationWindow authWindow = new ChatRoomAuthenticationWindow(chatRoomWrapper); authWindow.setVisible(true); } else if (itemName.equals("nickNameChatRoom")) { String nickName = null; nickName = ConfigurationManager.getChatRoomProperty( chatRoomWrapper.getParentProvider().getProtocolProvider(), chatRoomWrapper.getChatRoomID(), "userNickName"); ChatOperationReasonDialog reasonDialog = new ChatOperationReasonDialog( GuiActivator.getResources().getI18NString("service.gui.CHANGE_NICKNAME"), GuiActivator.getResources().getI18NString("service.gui.CHANGE_NICKNAME_LABEL")); reasonDialog.setReasonFieldText( nickName == null ? chatRoomWrapper.getParentProvider().getProtocolProvider().getAccountID().getUserID() : nickName); int result = reasonDialog.showDialog(); if (result == MessageDialog.OK_RETURN_CODE) { nickName = reasonDialog.getReason().trim(); } ConfigurationManager.updateChatRoomProperty( chatRoomWrapper.getParentProvider().getProtocolProvider(), chatRoomWrapper.getChatRoomID(), "userNickName", nickName); } }