public void actionPerformed(ActionEvent e) { if (e.getSource() == enableDefaultEncryption) { loadStates(); } else if (e.getSource() == cmdExpandAdvancedSettings) { pnlAdvancedSettings.setVisible(!pnlAdvancedSettings.isVisible()); } }
/** * 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; }
/** Initialize the panel containing the node. */ public PluginListCellRenderer() { super(new BorderLayout(8, 8)); JPanel mainPanel = new JPanel(new BorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); this.setBackground(Color.WHITE); this.setOpaque(true); mainPanel.setOpaque(false); this.nameVersionPanel.setOpaque(false); this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); this.nameLabel.setIconTextGap(2); this.nameLabel.setFont(this.getFont().deriveFont(Font.BOLD)); this.systemLabel.setFont(this.getFont().deriveFont(Font.BOLD)); this.nameVersionPanel.add(nameLabel); this.nameVersionPanel.add(versionLabel); mainPanel.add(nameVersionPanel, BorderLayout.NORTH); mainPanel.add(descriptionLabel, BorderLayout.CENTER); this.add(iconLabel, BorderLayout.WEST); this.add(mainPanel, BorderLayout.CENTER); this.add(stateLabel, BorderLayout.WEST); }
/** Creates an instance of <tt>SkinManagerPanel</tt>. */ public SkinManagerPanel() { super(new BorderLayout()); JPanel selectorPanel = new TransparentPanel(); selectorPanel.setLayout(new BoxLayout(selectorPanel, BoxLayout.Y_AXIS)); skinSelector.setAlignmentX(Component.CENTER_ALIGNMENT); skinSelector.addItemListener(new EnableDisableListener()); selectorPanel.add(skinSelector); rmButton.setAlignmentX(Component.CENTER_ALIGNMENT); rmButton.addActionListener(new RemoveListener()); selectorPanel.add(rmButton); enableDisableButton(); add(selectorPanel, BorderLayout.NORTH); }
/** * Paint a background for all groups and a round blue border and background when a cell is * selected. * * @param g the <tt>Graphics</tt> object used for painting */ @Override public void paintComponent(Graphics g) { super.paintComponent(g); g = g.create(); try { internalPaintComponent(g); } finally { g.dispose(); } }
/** * Creates an instance of <tt>ChatRoomConfigurationWindow</tt> and initializes the configuration * form. * * @param chatRoomName the name of the room * @param configForm the configuration form to load in this configuration window */ public ChatRoomConfigurationWindow(String chatRoomName, ChatRoomConfigurationForm configForm) { super(false); this.configForm = configForm; this.setTitle( GuiActivator.getResources() .getI18NString("service.gui.CHAT_ROOM_CONFIGURATION", new String[] {chatRoomName})); titlePanel.setTitleText( GuiActivator.getResources().getI18NString("service.gui.CHAT_ROOM_OPTIONS")); this.generalScrollPane.setPreferredSize(new Dimension(820, 520)); this.generalScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); this.generalScrollPane.setOpaque(false); this.generalScrollPane.getViewport().setOpaque(false); this.mainPanel.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15)); this.mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); this.saveButton.addActionListener(this); this.cancelButton.addActionListener(this); this.buttonsPanel.add(saveButton); this.buttonsPanel.add(cancelButton); this.generalScrollPane.getViewport().add(mainPanel); this.getContentPane().add(titlePanel, BorderLayout.NORTH); this.getContentPane().add(generalScrollPane, BorderLayout.CENTER); this.getContentPane().add(buttonsPanel, BorderLayout.SOUTH); titlePanel.setOpaque(false); buttonsPanel.setOpaque(false); mainPanel.setOpaque(false); generalScrollPane.setOpaque(false); this.loadConfigurationForm(); }
/** * Paints a customized background. * * @param g the <tt>Graphics</tt> object through which we paint */ @Override protected void paintComponent(Graphics g) { super.paintComponent(g); g = g.create(); if (!(treeNode instanceof GroupNode) && !isSelected) return; AntialiasingManager.activateAntialiasing(g); Graphics2D g2 = (Graphics2D) g; try { internalPaintComponent(g2); } finally { g.dispose(); } }
/** Creates an instance <tt>PropertiesEditorPanel</tt>. */ public PropertiesEditorPanel() { super(new BorderLayout()); /** * Instantiates the properties table and adds selection model and listener and adds a row sorter * to the table model */ ResourceManagementService r = PropertiesEditorActivator.getResourceManagementService(); String[] columnNames = new String[] {r.getI18NString("service.gui.NAME"), r.getI18NString("service.gui.VALUE")}; propsTable = new JTable(new PropsTableModel(initTableModel(), columnNames)); propsTable.setRowSorter(new TableRowSorter<TableModel>(propsTable.getModel())); propsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); PropsListSelectionListener selectionListener = new PropsListSelectionListener(); propsTable.getSelectionModel().addListSelectionListener(selectionListener); propsTable.getColumnModel().getSelectionModel().addListSelectionListener(selectionListener); JScrollPane scrollPane = new JScrollPane(propsTable); SearchField searchField = new SearchField("", propsTable); buttonsPanel = new ButtonsPanel(propsTable, searchField); centerPanel = new TransparentPanel(new BorderLayout()); centerPanel.add(scrollPane, BorderLayout.CENTER); centerPanel.add(buttonsPanel, BorderLayout.EAST); JLabel needRestart = new JLabel(r.getI18NString("plugin.propertieseditor.NEED_RESTART")); needRestart.setForeground(Color.RED); TransparentPanel searchPanel = new TransparentPanel(new BorderLayout(5, 0)); searchPanel.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5)); searchPanel.add(searchField, BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); add(searchPanel, BorderLayout.NORTH); add(centerPanel, BorderLayout.CENTER); add(needRestart, BorderLayout.SOUTH); }
/** * Draw the icon at the specified location. Paints this component as an icon. * * @param c the component which can be used as observer * @param g the <tt>Graphics</tt> object used for painting * @param x the position on the X coordinate * @param y the position on the Y coordinate */ public void paintIcon(Component c, Graphics g, int x, int y) { g = g.create(); try { Graphics2D g2 = (Graphics2D) g; AntialiasingManager.activateAntialiasing(g2); g2.setColor(Color.WHITE); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f)); g2.fillRoundRect(x, y, getIconWidth() - 1, getIconHeight() - 1, 10, 10); g2.setColor(Color.DARK_GRAY); g2.drawRoundRect(x, y, getIconWidth() - 1, getIconHeight() - 1, 10, 10); // Indent component content from the border. g2.translate(x + 5, y + 5); super.paint(g2); g2.translate(x, y); } finally { g.dispose(); } }
@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(); } }
/** * Shows/hides the security panel. * * @param isVisible <tt>true</tt> to show the security panel, <tt>false</tt> to hide it */ public void setSecurityPanelVisible(final boolean isVisible) { if (!SwingUtilities.isEventDispatchThread()) { SwingUtilities.invokeLater( new Runnable() { public void run() { setSecurityPanelVisible(isVisible); } }); return; } final JFrame callFrame = callRenderer.getCallContainer().getCallWindow().getFrame(); final JPanel glassPane = (JPanel) callFrame.getGlassPane(); if (!isVisible) { // Need to hide the security panel explicitly in order to keep the // fade effect. securityPanel.setVisible(false); glassPane.setVisible(false); glassPane.removeAll(); } else { glassPane.setLayout(null); glassPane.addMouseListener( new MouseListener() { public void mouseClicked(MouseEvent e) { redispatchMouseEvent(glassPane, e); } public void mouseEntered(MouseEvent e) { redispatchMouseEvent(glassPane, e); } public void mouseExited(MouseEvent e) { redispatchMouseEvent(glassPane, e); } public void mousePressed(MouseEvent e) { redispatchMouseEvent(glassPane, e); } public void mouseReleased(MouseEvent e) { redispatchMouseEvent(glassPane, e); } }); Point securityLabelPoint = securityStatusLabel.getLocation(); Point newPoint = SwingUtilities.convertPoint( securityStatusLabel.getParent(), securityLabelPoint.x, securityLabelPoint.y, callFrame); securityPanel.setBeginPoint(new Point((int) newPoint.getX() + 15, 0)); securityPanel.setBounds(0, (int) newPoint.getY() - 5, this.getWidth(), 130); glassPane.add(securityPanel); // Need to show the security panel explicitly in order to keep the // fade effect. securityPanel.setVisible(true); glassPane.setVisible(true); glassPane.addComponentListener( new ComponentAdapter() { /** Invoked when the component's size changes. */ @Override public void componentResized(ComponentEvent e) { if (glassPane.isVisible()) { glassPane.setVisible(false); callFrame.removeComponentListener(this); } } }); } }
/** 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); } }
/** Creating the configuration form */ private void init() { ResourceManagementService resources = LoggingUtilsActivator.getResourceService(); enableCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.ENABLE_DISABLE")); enableCheckBox.addActionListener(this); sipProtocolCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.sipaccregwizz.PROTOCOL_NAME")); sipProtocolCheckBox.addActionListener(this); jabberProtocolCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.jabberaccregwizz.PROTOCOL_NAME")); jabberProtocolCheckBox.addActionListener(this); String rtpDescription = resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP_DESCRIPTION"); rtpProtocolCheckBox = new SIPCommCheckBox( resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP") + " " + rtpDescription); rtpProtocolCheckBox.addActionListener(this); rtpProtocolCheckBox.setToolTipText(rtpDescription); ice4jProtocolCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_ICE4J")); ice4jProtocolCheckBox.addActionListener(this); JPanel mainPanel = new TransparentPanel(); add(mainPanel, BorderLayout.NORTH); mainPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); enableCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.gridx = 0; c.gridy = 0; mainPanel.add(enableCheckBox, c); String label = resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_DESCRIPTION"); JLabel descriptionLabel = new JLabel(label); descriptionLabel.setToolTipText(label); enableCheckBox.setToolTipText(label); descriptionLabel.setForeground(Color.GRAY); descriptionLabel.setFont(descriptionLabel.getFont().deriveFont(8)); c.gridy = 1; c.insets = new Insets(0, 25, 10, 0); mainPanel.add(descriptionLabel, c); final JPanel loggersButtonPanel = new TransparentPanel(new GridLayout(0, 1)); loggersButtonPanel.setBorder( BorderFactory.createTitledBorder(resources.getI18NString("service.gui.PROTOCOL"))); loggersButtonPanel.add(sipProtocolCheckBox); loggersButtonPanel.add(jabberProtocolCheckBox); loggersButtonPanel.add(rtpProtocolCheckBox); loggersButtonPanel.add(ice4jProtocolCheckBox); c.insets = new Insets(0, 20, 10, 0); c.gridy = 2; mainPanel.add(loggersButtonPanel, c); final JPanel advancedPanel = new TransparentPanel(new GridLayout(0, 2)); advancedPanel.setBorder( BorderFactory.createTitledBorder(resources.getI18NString("service.gui.ADVANCED"))); fileCountField.getDocument().addDocumentListener(this); fileSizeField.getDocument().addDocumentListener(this); fileCountLabel = new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_COUNT")); advancedPanel.add(fileCountLabel); advancedPanel.add(fileCountField); fileSizeLabel = new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_SIZE")); advancedPanel.add(fileSizeLabel); advancedPanel.add(fileSizeField); c.gridy = 3; mainPanel.add(advancedPanel, c); archiveButton = new JButton(resources.getI18NString("plugin.loggingutils.ARCHIVE_BUTTON")); archiveButton.addActionListener(this); c = new GridBagConstraints(); c.anchor = GridBagConstraints.LINE_START; c.weightx = 0; c.gridx = 0; c.gridy = 4; mainPanel.add(archiveButton, c); if (!StringUtils.isNullOrEmpty(getUploadLocation())) { uploadLogsButton = new JButton(resources.getI18NString("plugin.loggingutils.UPLOAD_LOGS_BUTTON")); uploadLogsButton.addActionListener(this); c.insets = new Insets(10, 0, 0, 0); c.gridy = 5; mainPanel.add(uploadLogsButton, c); } }
/** Shows a dialog with input for logs description. */ private void uploadLogs() { ResourceManagementService resources = LoggingUtilsActivator.getResourceService(); final SIPCommDialog dialog = new SIPCommDialog(false) { /** Serial version UID. */ private static final long serialVersionUID = 0L; /** * Dialog is closed. Do nothing. * * @param escaped <tt>true</tt> if this dialog has been closed by pressing */ @Override protected void close(boolean escaped) {} }; dialog.setModal(true); dialog.setTitle(resources.getI18NString("plugin.loggingutils.UPLOAD_LOGS_BUTTON")); Container container = dialog.getContentPane(); container.setLayout(new GridBagLayout()); JLabel descriptionLabel = new JLabel("Add a comment:"); final JTextArea commentTextArea = new JTextArea(); commentTextArea.setRows(4); final JButton uploadButton = new JButton(resources.getI18NString("plugin.loggingutils.UPLOAD_BUTTON")); final SIPCommTextField emailField = new SIPCommTextField(resources.getI18NString("plugin.loggingutils.ARCHIVE_UPREPORT_EMAIL")); final JCheckBox emailCheckBox = new SIPCommCheckBox("Email me when more information is available"); emailCheckBox.setSelected(true); emailCheckBox.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (!emailCheckBox.isSelected()) { uploadButton.setEnabled(true); emailField.setEnabled(false); } else { emailField.setEnabled(true); if (emailField.getText() != null && emailField.getText().trim().length() > 0) uploadButton.setEnabled(true); else uploadButton.setEnabled(false); } } }); emailField .getDocument() .addDocumentListener( new DocumentListener() { public void insertUpdate(DocumentEvent e) { updateButtonsState(); } public void removeUpdate(DocumentEvent e) { updateButtonsState(); } public void changedUpdate(DocumentEvent e) {} /** Check whether we should enable upload button. */ private void updateButtonsState() { if (emailCheckBox.isSelected() && emailField.getText() != null && emailField.getText().trim().length() > 0) uploadButton.setEnabled(true); else uploadButton.setEnabled(false); } }); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(10, 10, 3, 10); c.weightx = 1.0; c.gridx = 0; c.gridy = 0; container.add(descriptionLabel, c); c.insets = new Insets(0, 10, 10, 10); c.gridy = 1; container.add(new JScrollPane(commentTextArea), c); c.insets = new Insets(0, 10, 0, 10); c.gridy = 2; container.add(emailCheckBox, c); c.insets = new Insets(0, 10, 10, 10); c.gridy = 3; container.add(emailField, c); JButton cancelButton = new JButton(resources.getI18NString("service.gui.CANCEL")); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); uploadButton.setEnabled(false); uploadButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { try { final ArrayList<String> paramNames = new ArrayList<String>(); final ArrayList<String> paramValues = new ArrayList<String>(); if (emailCheckBox.isSelected()) { paramNames.add("Email"); paramValues.add(emailField.getText()); } paramNames.add("Description"); paramValues.add(commentTextArea.getText()); // don't block the UI thread we may need to show // some ui for password input if protected area on the way new Thread( new Runnable() { public void run() { uploadLogs( getUploadLocation(), LogsCollector.getDefaultFileName(), paramNames.toArray(new String[] {}), paramValues.toArray(new String[] {})); } }) .start(); } finally { dialog.dispose(); } } }); JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT)); buttonsPanel.add(uploadButton); buttonsPanel.add(cancelButton); c.anchor = GridBagConstraints.LINE_END; c.weightx = 0; c.gridy = 4; container.add(buttonsPanel, c); dialog.setVisible(true); }
/** Initializes this panel. */ private void init() { JPanel mainPanel = new TransparentPanel(new BorderLayout()); mainPanel.setBorder( BorderFactory.createTitledBorder( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sipaccregwizz.CREATE_ACCOUNT_TITLE"))); JPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1)); JPanel valuesPanel = new TransparentPanel(new GridLayout(0, 1)); JLabel usernameLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.USERNAME")); JLabel displayNameLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sipaccregwizz.DISPLAY_NAME")); JLabel passLabel = new JLabel(Sip2SipAccRegWizzActivator.getResources().getI18NString("service.gui.PASSWORD")); JLabel retypePasswordLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.RETYPE_PASSWORD")); JLabel emailLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.EMAIL")); labelsPanel.add(displayNameLabel); labelsPanel.add(usernameLabel); labelsPanel.add(passLabel); labelsPanel.add(retypePasswordLabel); labelsPanel.add(emailLabel); valuesPanel.add(displayNameField); valuesPanel.add(usernameField); valuesPanel.add(passField); valuesPanel.add(retypePassField); valuesPanel.add(emailField); JLabel emailDescriptionLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.EMAIL_NOTE"), SwingConstants.CENTER); emailDescriptionLabel.setForeground(Color.GRAY); emailDescriptionLabel.setFont(emailDescriptionLabel.getFont().deriveFont(8)); emailDescriptionLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 8, 10)); initErrorArea(); mainPanel.add(labelsPanel, BorderLayout.WEST); mainPanel.add(valuesPanel, BorderLayout.CENTER); mainPanel.add(emailDescriptionLabel, BorderLayout.SOUTH); this.add(mainPanel, BorderLayout.CENTER); JLabel infoLabel = new JLabel( Sip2SipAccRegWizzActivator.getResources() .getI18NString("plugin.sip2sipaccregwizz.INFO_NOTE"), SwingConstants.RIGHT); infoLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); infoLabel.setForeground(Color.GRAY); infoLabel.setFont(emailDescriptionLabel.getFont().deriveFont(8)); infoLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0)); infoLabel.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { Sip2SipAccRegWizzActivator.getBrowserLauncher().openURL("http://wiki.sip2sip.info"); } }); this.add(infoLabel, BorderLayout.SOUTH); }
private <T extends Enum<T>> void createControls(JPanel panel, ZrtpConfigureTableModel<T> model) { ResourceManagementService resources = NeomediaActivator.getResources(); final JButton upButton = new JButton(resources.getI18NString("impl.media.configform.UP")); upButton.setOpaque(false); final JButton downButton = new JButton(resources.getI18NString("impl.media.configform.DOWN")); downButton.setOpaque(false); Container buttonBar = new TransparentPanel(new GridLayout(0, 1)); buttonBar.add(upButton); buttonBar.add(downButton); panel.setBorder(BorderFactory.createEmptyBorder(MARGIN, MARGIN, MARGIN, MARGIN)); panel.setLayout(new GridBagLayout()); final JTable table = new JTable(model.getRowCount(), 2); table.setShowGrid(false); table.setTableHeader(null); table.setModel(model); // table.setFillsViewportHeight(true); // Since 1.6 only - nicer view /* * The first column contains the check boxes which enable/disable their * associated encodings and it doesn't make sense to make it wider than * the check boxes. */ TableColumnModel tableColumnModel = table.getColumnModel(); TableColumn tableColumn = tableColumnModel.getColumn(0); tableColumn.setMaxWidth(tableColumn.getMinWidth() + 5); table.doLayout(); GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.CENTER; constraints.fill = GridBagConstraints.BOTH; constraints.gridwidth = 1; constraints.gridx = 0; constraints.gridy = 1; constraints.weightx = 1; constraints.weighty = 1; panel.add(new JScrollPane(table), constraints); constraints.anchor = GridBagConstraints.NORTHEAST; constraints.fill = GridBagConstraints.NONE; constraints.gridwidth = 1; constraints.gridx = 1; constraints.gridy = 1; constraints.weightx = 0; constraints.weighty = 0; panel.add(buttonBar, constraints); ListSelectionListener tableSelectionListener = new ListSelectionListener() { @SuppressWarnings("unchecked") public void valueChanged(ListSelectionEvent event) { if (table.getSelectedRowCount() == 1) { int selectedRow = table.getSelectedRow(); if (selectedRow > -1) { ZrtpConfigureTableModel<T> model = (ZrtpConfigureTableModel<T>) table.getModel(); upButton.setEnabled(selectedRow > 0 && model.checkEnableUp(selectedRow)); downButton.setEnabled( selectedRow < (table.getRowCount() - 1) && model.checkEnableDown(selectedRow)); return; } } upButton.setEnabled(false); downButton.setEnabled(false); } }; table.getSelectionModel().addListSelectionListener(tableSelectionListener); TableModelListener tableListener = new TableModelListener() { @SuppressWarnings("unchecked") public void tableChanged(TableModelEvent e) { if (table.getSelectedRowCount() == 1) { int selectedRow = table.getSelectedRow(); if (selectedRow > -1) { ZrtpConfigureTableModel<T> model = (ZrtpConfigureTableModel<T>) table.getModel(); upButton.setEnabled(selectedRow > 0 && model.checkEnableUp(selectedRow)); downButton.setEnabled( selectedRow < (table.getRowCount() - 1) && model.checkEnableDown(selectedRow)); return; } } upButton.setEnabled(false); downButton.setEnabled(false); } }; table.getModel().addTableModelListener(tableListener); tableSelectionListener.valueChanged(null); ActionListener buttonListener = new ActionListener() { @SuppressWarnings("unchecked") public void actionPerformed(ActionEvent event) { Object source = event.getSource(); boolean up; if (source == upButton) up = true; else if (source == downButton) up = false; else return; int index = ((ZrtpConfigureTableModel<T>) table.getModel()) .move(table.getSelectedRow(), up, up); table.getSelectionModel().setSelectionInterval(index, index); } }; upButton.addActionListener(buttonListener); downButton.addActionListener(buttonListener); }
/** Creates an instance of <tt>ZrtpConfigurePanel</tt>. */ public ZrtpConfigurePanel() { super(new BorderLayout()); ResourceManagementService resources = NeomediaActivator.getResources(); JPanel mainPanel = new TransparentPanel(new BorderLayout(0, 10)); final JButton stdButton = new JButton(resources.getI18NString("impl.media.security.zrtp.STANDARD")); stdButton.setOpaque(false); final JButton mandButton = new JButton(resources.getI18NString("impl.media.security.zrtp.MANDATORY")); mandButton.setOpaque(false); final JButton saveButton = new JButton(resources.getI18NString("service.gui.SAVE")); saveButton.setOpaque(false); JPanel buttonBar = new TransparentPanel(new GridLayout(1, 7)); buttonBar.add(stdButton); buttonBar.add(mandButton); buttonBar.add(Box.createHorizontalStrut(10)); buttonBar.add(saveButton); ConfigurationService cfg = NeomediaActivator.getConfigurationService(); boolean trusted = cfg.getBoolean(TRUSTED_PROP, false); boolean sasSign = cfg.getBoolean(SASSIGN_PROP, false); JPanel checkBar = new TransparentPanel(new GridLayout(1, 2)); final JCheckBox trustedMitM = new SIPCommCheckBox(resources.getI18NString("impl.media.security.zrtp.TRUSTED"), trusted); final JCheckBox sasSignature = new SIPCommCheckBox( resources.getI18NString("impl.media.security.zrtp.SASSIGNATURE"), sasSign); checkBar.add(trustedMitM); checkBar.add(sasSignature); mainPanel.add(checkBar, BorderLayout.NORTH); ActionListener buttonListener = new ActionListener() { public void actionPerformed(ActionEvent event) { Object source = event.getSource(); if (source == stdButton) { inActive.clear(); active.setStandardConfig(); pkc.setStandard(); hc.setStandard(); sc.setStandard(); cc.setStandard(); lc.setStandard(); } else if (source == mandButton) { inActive.clear(); active.setMandatoryOnly(); pkc.setStandard(); hc.setStandard(); sc.setStandard(); cc.setStandard(); lc.setStandard(); } else if (source == saveButton) { ConfigurationService cfg = NeomediaActivator.getConfigurationService(); cfg.setProperty(TRUSTED_PROP, String.valueOf(active.isTrustedMitM())); cfg.setProperty(SASSIGN_PROP, String.valueOf(active.isSasSignature())); pkc.saveConfig(); hc.saveConfig(); sc.saveConfig(); cc.saveConfig(); lc.saveConfig(); } else return; } }; stdButton.addActionListener(buttonListener); mandButton.addActionListener(buttonListener); saveButton.addActionListener(buttonListener); ItemListener itemListener = new ItemListener() { public void itemStateChanged(ItemEvent e) { Object source = e.getItemSelectable(); if (source == trustedMitM) { active.setTrustedMitM(trustedMitM.isSelected()); } else if (source == sasSignature) { active.setSasSignature(sasSignature.isSelected()); } } }; trustedMitM.addItemListener(itemListener); sasSignature.addItemListener(itemListener); JTabbedPane algorithmsPane = new SIPCommTabbedPane(); algorithmsPane.addTab(resources.getI18NString("impl.media.security.zrtp.PUB_KEYS"), pkc); algorithmsPane.addTab(resources.getI18NString("impl.media.security.zrtp.HASHES"), hc); algorithmsPane.addTab(resources.getI18NString("impl.media.security.zrtp.SYM_CIPHERS"), cc); algorithmsPane.addTab(resources.getI18NString("impl.media.security.zrtp.SAS_TYPES"), sc); algorithmsPane.addTab(resources.getI18NString("impl.media.security.zrtp.SRTP_LENGTHS"), lc); algorithmsPane.setMinimumSize(new Dimension(400, 100)); algorithmsPane.setPreferredSize(new Dimension(400, 200)); mainPanel.add(algorithmsPane, BorderLayout.CENTER); mainPanel.add(buttonBar, BorderLayout.SOUTH); add(mainPanel); }
/** * Creates an instance of <tt>ShowPreviewDialog</tt> * * @param chatPanel The <tt>ChatConversationPanel</tt> that is associated with this dialog. */ ShowPreviewDialog(final ChatConversationPanel chatPanel) { this.chatPanel = chatPanel; this.setTitle( GuiActivator.getResources().getI18NString("service.gui.SHOW_PREVIEW_DIALOG_TITLE")); okButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.OK")); cancelButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.CANCEL")); JPanel mainPanel = new TransparentPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); // mainPanel.setPreferredSize(new Dimension(200, 150)); this.getContentPane().add(mainPanel); JTextPane descriptionMsg = new JTextPane(); descriptionMsg.setEditable(false); descriptionMsg.setOpaque(false); descriptionMsg.setText( GuiActivator.getResources().getI18NString("service.gui.SHOW_PREVIEW_WARNING_DESCRIPTION")); Icon warningIcon = null; try { warningIcon = new ImageIcon( ImageIO.read( GuiActivator.getResources().getImageURL("service.gui.icons.WARNING_ICON"))); } catch (IOException e) { logger.debug("failed to load the warning icon"); } JLabel warningSign = new JLabel(warningIcon); JPanel warningPanel = new TransparentPanel(); warningPanel.setLayout(new BoxLayout(warningPanel, BoxLayout.X_AXIS)); warningPanel.add(warningSign); warningPanel.add(Box.createHorizontalStrut(10)); warningPanel.add(descriptionMsg); enableReplacement = new JCheckBox( GuiActivator.getResources() .getI18NString("plugin.chatconfig.replacement.ENABLE_REPLACEMENT_STATUS")); enableReplacement.setOpaque(false); enableReplacement.setSelected(cfg.getBoolean(ReplacementProperty.REPLACEMENT_ENABLE, true)); enableReplacementProposal = new JCheckBox( GuiActivator.getResources() .getI18NString("plugin.chatconfig.replacement.ENABLE_REPLACEMENT_PROPOSAL")); enableReplacementProposal.setOpaque(false); JPanel checkBoxPanel = new TransparentPanel(); checkBoxPanel.setLayout(new BoxLayout(checkBoxPanel, BoxLayout.Y_AXIS)); checkBoxPanel.add(enableReplacement); checkBoxPanel.add(enableReplacementProposal); JPanel buttonsPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER)); buttonsPanel.add(okButton); buttonsPanel.add(cancelButton); mainPanel.add(warningPanel); mainPanel.add(Box.createVerticalStrut(10)); mainPanel.add(checkBoxPanel); mainPanel.add(buttonsPanel); okButton.addActionListener(this); cancelButton.addActionListener(this); this.setPreferredSize(new Dimension(390, 230)); }
private void initComponents() { setLayout(new BorderLayout()); final JPanel mainPanel = new TransparentPanel(); add(mainPanel, BorderLayout.NORTH); mainPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.anchor = GridBagConstraints.LINE_START; c.fill = GridBagConstraints.HORIZONTAL; // general encryption option enableDefaultEncryption = new SIPCommCheckBox( UtilActivator.getResources() .getI18NString("plugin.sipaccregwizz.ENABLE_DEFAULT_ENCRYPTION"), regform.isDefaultEncryption()); enableDefaultEncryption.addActionListener(this); mainPanel.add(enableDefaultEncryption, c); // warning message and button to show advanced options JLabel lblWarning = new JLabel(); lblWarning.setBorder(new EmptyBorder(10, 5, 10, 0)); lblWarning.setText( UtilActivator.getResources() .getI18NString( "plugin.sipaccregwizz.SECURITY_WARNING", new String[] { UtilActivator.getResources().getSettingsString("service.gui.APPLICATION_NAME") })); c.gridy++; mainPanel.add(lblWarning, c); cmdExpandAdvancedSettings = new JLabel(); cmdExpandAdvancedSettings.setBorder(new EmptyBorder(0, 5, 0, 0)); cmdExpandAdvancedSettings.setIcon( UtilActivator.getResources().getImage("service.gui.icons.RIGHT_ARROW_ICON")); cmdExpandAdvancedSettings.setText( UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.SHOW_ADVANCED")); cmdExpandAdvancedSettings.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { cmdExpandAdvancedSettings.setIcon( UtilActivator.getResources() .getImage( pnlAdvancedSettings.isVisible() ? "service.gui.icons.RIGHT_ARROW_ICON" : "service.gui.icons.DOWN_ARROW_ICON")); pnlAdvancedSettings.setVisible(!pnlAdvancedSettings.isVisible()); pnlAdvancedSettings.revalidate(); } }); c.gridy++; mainPanel.add(cmdExpandAdvancedSettings, c); pnlAdvancedSettings = new TransparentPanel(); pnlAdvancedSettings.setLayout(new GridBagLayout()); pnlAdvancedSettings.setVisible(false); c.gridy++; mainPanel.add(pnlAdvancedSettings, c); c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.gridwidth = 2; c.gridheight = 1; c.anchor = GridBagConstraints.LINE_START; c.fill = GridBagConstraints.HORIZONTAL; pnlAdvancedSettings.add(new JSeparator(), c); // Encryption protcol preferences. JLabel lblEncryptionProtocolPreferences = new JLabel(); lblEncryptionProtocolPreferences.setText( UtilActivator.getResources() .getI18NString("plugin.sipaccregwizz.ENCRYPTION_PROTOCOL_PREFERENCES")); c.gridy++; pnlAdvancedSettings.add(lblEncryptionProtocolPreferences, c); int nbEncryptionProtocols = ENCRYPTION_PROTOCOLS.length; String[] encryptions = new String[nbEncryptionProtocols]; boolean[] selectedEncryptions = new boolean[nbEncryptionProtocols]; this.encryptionConfigurationTableModel = new EncryptionConfigurationTableModel(encryptions, selectedEncryptions); loadEncryptionProtocols(new HashMap<String, Integer>(), new HashMap<String, Boolean>()); this.encryptionProtocolPreferences = new PriorityTable(this.encryptionConfigurationTableModel, 60); this.encryptionConfigurationTableModel.addTableModelListener(this); c.gridy++; pnlAdvancedSettings.add(this.encryptionProtocolPreferences, c); // ZRTP JLabel lblZrtpOption = new JLabel(); lblZrtpOption.setBorder(new EmptyBorder(5, 5, 5, 0)); lblZrtpOption.setText( UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.ZRTP_OPTION")); c.gridx = 0; c.gridy++; c.gridwidth = 1; pnlAdvancedSettings.add(lblZrtpOption, c); c.gridx = 1; pnlAdvancedSettings.add(new JSeparator(), c); enableSipZrtpAttribute = new SIPCommCheckBox( UtilActivator.getResources() .getI18NString("plugin.sipaccregwizz.ENABLE_SIPZRTP_ATTRIBUTE"), regform.isSipZrtpAttribute()); c.gridx = 0; c.gridy++; c.gridwidth = 2; pnlAdvancedSettings.add(enableSipZrtpAttribute, c); // SDES JLabel lblSDesOption = new JLabel(); lblSDesOption.setBorder(new EmptyBorder(5, 5, 5, 0)); lblSDesOption.setText( UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.SDES_OPTION")); c.gridx = 0; c.gridy++; c.gridwidth = 1; pnlAdvancedSettings.add(lblSDesOption, c); c.gridx = 1; pnlAdvancedSettings.add(new JSeparator(), c); JLabel lblCipherInfo = new JLabel(); lblCipherInfo.setText( UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.CIPHER_SUITES")); c.gridx = 0; c.gridy++; c.gridwidth = 2; pnlAdvancedSettings.add(lblCipherInfo, c); cipherModel = new CipherTableModel(regform.getSDesCipherSuites()); tabCiphers = new JTable(cipherModel); tabCiphers.setShowGrid(false); tabCiphers.setTableHeader(null); TableColumnModel tableColumnModel = tabCiphers.getColumnModel(); TableColumn tableColumn = tableColumnModel.getColumn(0); tableColumn.setMaxWidth(tableColumn.getMinWidth()); JScrollPane scrollPane = new JScrollPane(tabCiphers); scrollPane.setPreferredSize(new Dimension(tabCiphers.getWidth(), 100)); c.gridy++; pnlAdvancedSettings.add(scrollPane, c); // SAVP selection c.gridx = 0; c.gridwidth = 1; JLabel lblSavpOption = new JLabel(); lblSavpOption.setBorder(new EmptyBorder(5, 5, 5, 0)); lblSavpOption.setText( UtilActivator.getResources().getI18NString("plugin.sipaccregwizz.SAVP_OPTION")); if (this.displaySavpOtions) { c.gridy++; pnlAdvancedSettings.add(lblSavpOption, c); } c.gridx = 1; if (this.displaySavpOtions) { pnlAdvancedSettings.add(new JSeparator(), c); } cboSavpOption = new JComboBox(new SavpOption[] {new SavpOption(0), new SavpOption(1), new SavpOption(2)}); c.gridx = 0; c.gridwidth = 2; c.insets = new Insets(0, 20, 0, 0); if (this.displaySavpOtions) { c.gridy++; pnlAdvancedSettings.add(cboSavpOption, c); } }