/** 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); } }
/** * 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; }
/** * Handles the <tt>ActionEvent</tt> which occurred when user clicks the Search button. * * @param e the <tt>ActionEvent</tt> that notified us of the button click */ public void actionPerformed(ActionEvent e) { JButton button = (JButton) e.getSource(); String buttonName = button.getName(); if (buttonName.equalsIgnoreCase("search")) { historyWindow.showHistoryByKeyword(searchTextField.getText()); } }
/** 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")); }
/** * 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(); }
/** * 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(); }
/** * Handles the <tt>ActionEvent</tt>. In order to rename the contact invokes the <code> * renameMetaContact</code> method of the current <tt>MetaContactListService</tt>. */ public void actionPerformed(ActionEvent e) { JButton button = (JButton) e.getSource(); String name = button.getName(); if (name.equals("rename")) { if (metaContact != null) { new Thread() { public void run() { clist.renameMetaContact(metaContact, renameContactPanel.getNewName()); } }.start(); } } this.dispose(); }
/** * Calls the given treeNode. * * @param treeNode the <tt>TreeNode</tt> to call */ private void call(TreeNode treeNode, JButton button, boolean isVideo, boolean isDesktopSharing) { if (!(treeNode instanceof ContactNode)) return; UIContact contactDescriptor = ((ContactNode) treeNode).getContactDescriptor(); Point location = new Point(button.getX(), button.getY() + button.getHeight()); SwingUtilities.convertPointToScreen(location, treeContactList); location.y = location.y + treeContactList.getPathBounds(treeContactList.getSelectionPath()).y; location.x += 8; location.y -= 8; CallManager.call(contactDescriptor, isVideo, isDesktopSharing, treeContactList, location); }
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); } }); }
/** * Action performed on various action links(buttons). * * @param e the action. */ public void actionPerformed(ActionEvent e) { JButton src = (JButton) e.getSource(); if (src instanceof SIPCommButton) { // Load image int index = Integer.parseInt(src.getName()); BufferedImage image = AvatarStackManager.loadImage(index); // Set the new image setNewImage(image); } else if (src.getName().equals("chooseButton")) { // Open the image picker Image currentImage = this.avatarImage.getAvatar(); ImagePickerDialog dialog = new ImagePickerDialog(96, 96); byte[] bimage = dialog.showDialog(currentImage); if (bimage == null) return; // New image BufferedImage image = ImageUtils.getBufferedImage(new ImageIcon(bimage).getImage()); // Store image if (this.nextImageIndex == MAX_STORED_IMAGES) { // No more place to store images // Pop the first element (index 0) AvatarStackManager.popFirstImage(MAX_STORED_IMAGES); this.nextImageIndex = MAX_STORED_IMAGES - 1; } // Store the new image on hard drive AvatarStackManager.storeImage(image, this.nextImageIndex); // Inform protocols about the new image setNewImage(image); } else if (src.getName().equals("removeButton")) { // Removes the current photo. setNewImage(null); } else if (src.getName().equals("clearButton")) { clearRecentImages(); } setVisible(false); }
/** * 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(); } }
/** 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); } }); }
/** Constructs the <tt>SearchPanel</tt>. */ private void init() { String searchString = GuiActivator.getResources().getI18NString("service.gui.SEARCH"); JLabel searchLabel = new JLabel(searchString + ": "); searchButton = new JButton(searchString, new ImageIcon(ImageLoader.getImage(ImageLoader.SEARCH_ICON))); this.searchTextField.getDocument().addDocumentListener(this); this.add(searchLabel, BorderLayout.WEST); this.add(searchTextField, BorderLayout.CENTER); searchButton.setName("search"); searchButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.SEARCH")); searchButton.addActionListener(this); this.historyWindow.getRootPane().setDefaultButton(searchButton); this.add(searchButton, BorderLayout.EAST); }
/** * Resets the rollover state of all rollover components in the current cell except the component * given as a parameter. * * @param excludeComponent the component to exclude from the reset */ public void resetRolloverState(Component excludeComponent) { if (!chatButton.equals(excludeComponent)) chatButton.getModel().setRollover(false); if (!callButton.equals(excludeComponent)) callButton.getModel().setRollover(false); if (!callVideoButton.equals(excludeComponent)) callVideoButton.getModel().setRollover(false); if (!desktopSharingButton.equals(excludeComponent)) desktopSharingButton.getModel().setRollover(false); if (!addContactButton.equals(excludeComponent)) addContactButton.getModel().setRollover(false); if (customActionButtons != null) { Iterator<JButton> buttonsIter = customActionButtons.iterator(); while (buttonsIter.hasNext()) { JButton button = buttonsIter.next(); if (!button.equals(excludeComponent)) button.getModel().setRollover(false); } } if (customActionButtonsUIGroup != null) { Iterator<JButton> buttonsIter = customActionButtonsUIGroup.iterator(); while (buttonsIter.hasNext()) { JButton button = buttonsIter.next(); if (!button.equals(excludeComponent)) button.getModel().setRollover(false); } } }
/** * Handles buttons action events. * * @param evt the <tt>ActionEvent</tt> that notified us */ public void actionPerformed(ActionEvent evt) { JButton sourceButton = (JButton) evt.getSource(); if (sourceButton.equals(openFileButton)) { this.openFile(downloadFile); } else if (sourceButton.equals(openFolderButton)) { try { File downloadDir = GuiActivator.getFileAccessService().getDefaultDownloadDirectory(); GuiActivator.getDesktopService().open(downloadDir); } catch (IllegalArgumentException e) { if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e); this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_DOES_NOT_EXIST")); } catch (NullPointerException e) { if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e); this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_DOES_NOT_EXIST")); } catch (UnsupportedOperationException e) { if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e); this.showErrorMessage(resources.getI18NString("service.gui.FILE_OPEN_NOT_SUPPORTED")); } catch (SecurityException e) { if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e); this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_OPEN_NO_PERMISSION")); } catch (IOException e) { if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e); this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_OPEN_NO_APPLICATION")); } catch (Exception e) { if (logger.isDebugEnabled()) logger.debug("Unable to open file.", e); this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_OPEN_FAILED")); } } else if (sourceButton.equals(cancelButton)) { if (fileTransfer != null) fileTransfer.cancel(); } }
/** Resets the rollover state of all rollover components in the current cell. */ public void resetRolloverState() { chatButton.getModel().setRollover(false); callButton.getModel().setRollover(false); callVideoButton.getModel().setRollover(false); desktopSharingButton.getModel().setRollover(false); addContactButton.getModel().setRollover(false); if (customActionButtons != null) { Iterator<JButton> buttonsIter = customActionButtons.iterator(); while (buttonsIter.hasNext()) { JButton button = buttonsIter.next(); button.getModel().setRollover(false); } } if (customActionButtonsUIGroup != null) { Iterator<JButton> buttonsIter = customActionButtonsUIGroup.iterator(); while (buttonsIter.hasNext()) { JButton button = buttonsIter.next(); button.getModel().setRollover(false); } } }
/** * 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(); }
/** 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(); }
/** * Automatically press the cancel button when this dialog has been escaped. * * @param escaped indicates if this dialog has been closed by pressing the ESC key */ @Override protected void close(boolean escaped) { if (escaped) cancelButton.doClick(); }
/** * 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(); }
/** 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); }
/** Reloads search button icon. */ public void loadSkin() { searchButton.setIcon(new ImageIcon(ImageLoader.getImage(ImageLoader.SEARCH_ICON))); }
/** * 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)); }
/** * Saves all configuration settings when the "Save" button is pressed. * * @param e the <tt>ActionEvent</tt> that notified us of the button action */ public void actionPerformed(ActionEvent e) { JButton button = (JButton) e.getSource(); if (button.equals(saveButton)) { Iterator<ChatRoomConfigurationFormField> configurationSet = configForm.getConfigurationSet(); while (configurationSet.hasNext()) { ChatRoomConfigurationFormField formField = configurationSet.next(); // If the field is of type fixed the user could not change it, // so we skip it. if (formField.getType().equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) continue; JComponent c = uiFieldsTable.get(formField.getName()); if (c instanceof JTextComponent) { String newValue = ((JTextComponent) c).getText(); if (formField.getType().equals(ChatRoomConfigurationFormField.TYPE_ID_MULTI)) { // extract values StringTokenizer idTokens = new StringTokenizer(newValue, System.getProperty("line.separator")); while (idTokens.hasMoreTokens()) { formField.addValue(idTokens.nextToken()); } } else formField.addValue(newValue); } else if (c instanceof AbstractButton) { boolean isSelected = ((AbstractButton) c).isSelected(); formField.addValue(isSelected); } else if (c instanceof JComboBox) { Object selectedObject = ((JComboBox) c).getSelectedItem(); formField.addValue(selectedObject); } else if (c instanceof JPanel) { Component[] components = c.getComponents(); for (Component comp : components) { if (!(comp instanceof JCheckBox)) continue; JCheckBox checkBox = (JCheckBox) comp; formField.addValue(checkBox.getText()); } } } new Thread() { @Override public void run() { try { configForm.submit(); } catch (Exception e) { new ErrorDialog( ChatRoomConfigurationWindow.this, GuiActivator.getResources().getI18NString("service.gui.ERROR"), GuiActivator.getResources() .getI18NString("service.gui.CHAT_ROOM_CONFIGURATION_SUBMIT_FAILED"), e) .showDialog(); } } }.start(); } this.dispose(); }