@Override public void chatLinkClicked(URI url) { String action = url.getPath(); if (action.equals("/SHOWPREVIEW")) { enableReplacement.setSelected(cfg.getBoolean(ReplacementProperty.REPLACEMENT_ENABLE, true)); enableReplacementProposal.setSelected( cfg.getBoolean(ReplacementProperty.REPLACEMENT_PROPOSAL, true)); currentMessageID = url.getQuery(); currentLinkPosition = url.getFragment(); this.setVisible(true); this.setLocationRelativeTo(chatPanel); } }
/** * 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)); }
/** Loads the configuration form obtained from the chat room. */ protected void loadConfigurationForm() { Iterator<ChatRoomConfigurationFormField> configurationSet = configForm.getConfigurationSet(); while (configurationSet.hasNext()) { ChatRoomConfigurationFormField formField = configurationSet.next(); Iterator<?> values = formField.getValues(); Iterator<String> options = formField.getOptions(); JComponent field; JLabel label = new JLabel("", JLabel.RIGHT); if (formField.getLabel() != null) label.setText(formField.getLabel() + ": "); String fieldType = formField.getType(); if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_BOOLEAN)) { // Create a check box when the field is of type boolean. field = new SIPCommCheckBox(formField.getLabel()); label.setText(""); if (values.hasNext()) { ((JCheckBox) field).setSelected((Boolean) values.next()); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) { field = new JLabel(); if (values.hasNext()) { String value = values.next().toString(); ((JLabel) field).setText(value); field.setFont(new Font(null, Font.ITALIC, 10)); field.setForeground(Color.GRAY); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_LIST_MULTI)) { field = new TransparentPanel(new GridLayout(0, 1)); field.setBorder(BorderFactory.createLineBorder(Color.GRAY)); Hashtable<Object, JCheckBox> optionCheckBoxes = new Hashtable<Object, JCheckBox>(); while (options.hasNext()) { Object option = options.next(); JCheckBox checkBox = new SIPCommCheckBox(option.toString()); field.add(checkBox); optionCheckBoxes.put(option, checkBox); } while (values.hasNext()) { Object value = values.next(); (optionCheckBoxes.get(value)).setSelected(true); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_LIST_SINGLE)) { field = new JComboBox(); while (options.hasNext()) { ((JComboBox) field).addItem(options.next()); } if (values.hasNext()) { ((JComboBox) field).setSelectedItem(values.next()); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_MULTI)) { field = new JEditorPane(); if (values.hasNext()) { String value = values.next().toString(); ((JEditorPane) field).setText(value); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_SINGLE) || fieldType.equals(ChatRoomConfigurationFormField.TYPE_ID_SINGLE)) { field = new JTextField(); if (values.hasNext()) { String value = values.next().toString(); ((JTextField) field).setText(value); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_PRIVATE)) { field = new JPasswordField(); if (values.hasNext()) { String value = values.next().toString(); ((JPasswordField) field).setText(value); } } else if (fieldType.equals(ChatRoomConfigurationFormField.TYPE_ID_MULTI)) { StringBuffer buff = new StringBuffer(); while (values.hasNext()) { String value = values.next().toString(); buff.append(value); if (values.hasNext()) buff.append(System.getProperty("line.separator")); } field = new JTextArea(buff.toString()); } else { if (label.getText() == null) continue; field = new JTextField(); if (values.hasNext()) { String value = values.next().toString(); ((JTextField) field).setText(value); } } // If the field is not fixed (i.e. could be changed) we would like // to save it in a list in order to use it later when user saves // the configuration data. if (!fieldType.equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) { uiFieldsTable.put(formField.getName(), field); } JPanel fieldPanel = new TransparentPanel(new GridLayout(1, 2)); fieldPanel.setOpaque(false); if (!(field instanceof JLabel)) fieldPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0)); else fieldPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 1, 0)); fieldPanel.add(label); fieldPanel.add(field); this.mainPanel.add(fieldPanel); } }