/** * Creates all the controls (including encoding) for a type(AUDIO or VIDEO) * * @param type the type. * @return the build Component. */ private static Component createControls(int type) { ConfigurationService cfg = NeomediaActivator.getConfigurationService(); SIPCommTabbedPane container = new SIPCommTabbedPane(); ResourceManagementService res = NeomediaActivator.getResources(); if ((cfg == null) || !cfg.getBoolean(DEVICES_DISABLED_PROP, false)) { container.insertTab( res.getI18NString("impl.media.configform.DEVICES"), null, createBasicControls(type), null, 0); } if ((cfg == null) || !cfg.getBoolean(ENCODINGS_DISABLED_PROP, false)) { container.insertTab( res.getI18NString("impl.media.configform.ENCODINGS"), null, new PriorityTable( new EncodingConfigurationTableModel(mediaService.getEncodingConfiguration(), type), 100), null, 1); } if ((type == DeviceConfigurationComboBoxModel.VIDEO) && ((cfg == null) || !cfg.getBoolean(VIDEO_MORE_SETTINGS_DISABLED_PROP, false))) { container.insertTab( res.getI18NString("impl.media.configform.VIDEO_MORE_SETTINGS"), null, createVideoAdvancedSettings(), null, 2); } return container; }
/** 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); }
/** * 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; }
/** 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); }
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); }