/** * Creates the video advanced settings. * * @return video advanced settings panel. */ private static Component createVideoAdvancedSettings() { ResourceManagementService resources = NeomediaActivator.getResources(); final DeviceConfiguration deviceConfig = mediaService.getDeviceConfiguration(); TransparentPanel centerPanel = new TransparentPanel(new GridBagLayout()); centerPanel.setMaximumSize(new Dimension(WIDTH, 150)); JButton resetDefaultsButton = new JButton(resources.getI18NString("impl.media.configform.VIDEO_RESET")); JPanel resetButtonPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT)); resetButtonPanel.add(resetDefaultsButton); final JPanel centerAdvancedPanel = new TransparentPanel(new BorderLayout()); centerAdvancedPanel.add(centerPanel, BorderLayout.NORTH); centerAdvancedPanel.add(resetButtonPanel, BorderLayout.SOUTH); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.NORTHWEST; constraints.insets = new Insets(5, 5, 0, 0); constraints.gridx = 0; constraints.weightx = 0; constraints.weighty = 0; constraints.gridy = 0; centerPanel.add( new JLabel(resources.getI18NString("impl.media.configform.VIDEO_RESOLUTION")), constraints); constraints.gridy = 1; constraints.insets = new Insets(0, 0, 0, 0); final JCheckBox frameRateCheck = new SIPCommCheckBox(resources.getI18NString("impl.media.configform.VIDEO_FRAME_RATE")); centerPanel.add(frameRateCheck, constraints); constraints.gridy = 2; constraints.insets = new Insets(5, 5, 0, 0); centerPanel.add( new JLabel(resources.getI18NString("impl.media.configform.VIDEO_PACKETS_POLICY")), constraints); constraints.weightx = 1; constraints.gridx = 1; constraints.gridy = 0; constraints.insets = new Insets(5, 0, 0, 5); Object[] resolutionValues = new Object[DeviceConfiguration.SUPPORTED_RESOLUTIONS.length + 1]; System.arraycopy( DeviceConfiguration.SUPPORTED_RESOLUTIONS, 0, resolutionValues, 1, DeviceConfiguration.SUPPORTED_RESOLUTIONS.length); final JComboBox sizeCombo = new JComboBox(resolutionValues); sizeCombo.setRenderer(new ResolutionCellRenderer()); sizeCombo.setEditable(false); centerPanel.add(sizeCombo, constraints); // default value is 20 final JSpinner frameRate = new JSpinner(new SpinnerNumberModel(20, 5, 30, 1)); frameRate.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { deviceConfig.setFrameRate( ((SpinnerNumberModel) frameRate.getModel()).getNumber().intValue()); } }); constraints.gridy = 1; constraints.insets = new Insets(0, 0, 0, 5); centerPanel.add(frameRate, constraints); frameRateCheck.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (frameRateCheck.isSelected()) { deviceConfig.setFrameRate( ((SpinnerNumberModel) frameRate.getModel()).getNumber().intValue()); } else // unlimited framerate deviceConfig.setFrameRate(-1); frameRate.setEnabled(frameRateCheck.isSelected()); } }); final JSpinner videoMaxBandwidth = new JSpinner( new SpinnerNumberModel(deviceConfig.getVideoMaxBandwidth(), 1, Integer.MAX_VALUE, 1)); videoMaxBandwidth.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { deviceConfig.setVideoMaxBandwidth( ((SpinnerNumberModel) videoMaxBandwidth.getModel()).getNumber().intValue()); } }); constraints.gridx = 1; constraints.gridy = 2; constraints.insets = new Insets(0, 0, 5, 5); centerPanel.add(videoMaxBandwidth, constraints); resetDefaultsButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // reset to defaults sizeCombo.setSelectedIndex(0); frameRateCheck.setSelected(false); frameRate.setEnabled(false); frameRate.setValue(20); // unlimited framerate deviceConfig.setFrameRate(-1); videoMaxBandwidth.setValue(DeviceConfiguration.DEFAULT_VIDEO_MAX_BANDWIDTH); } }); // load selected value or auto Dimension videoSize = deviceConfig.getVideoSize(); if ((videoSize.getHeight() != DeviceConfiguration.DEFAULT_VIDEO_HEIGHT) && (videoSize.getWidth() != DeviceConfiguration.DEFAULT_VIDEO_WIDTH)) sizeCombo.setSelectedItem(deviceConfig.getVideoSize()); else sizeCombo.setSelectedIndex(0); sizeCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Dimension selectedVideoSize = (Dimension) sizeCombo.getSelectedItem(); if (selectedVideoSize == null) { // the auto value, default one selectedVideoSize = new Dimension( DeviceConfiguration.DEFAULT_VIDEO_WIDTH, DeviceConfiguration.DEFAULT_VIDEO_HEIGHT); } deviceConfig.setVideoSize(selectedVideoSize); } }); frameRateCheck.setSelected( deviceConfig.getFrameRate() != DeviceConfiguration.DEFAULT_VIDEO_FRAMERATE); frameRate.setEnabled(frameRateCheck.isSelected()); if (frameRate.isEnabled()) frameRate.setValue(deviceConfig.getFrameRate()); return centerAdvancedPanel; }
/** 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); } }
/** 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); }
/** 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); }
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); }