Esempio n. 1
0
  /**
   * 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;
  }
Esempio n. 2
0
  /**
   * 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);
              }
            }
          });
    }
  }
Esempio n. 3
0
  /**
   * 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;
  }
Esempio n. 4
0
  /**
   * Creates basic controls for a type (AUDIO or VIDEO).
   *
   * @param type the type.
   * @return the build Component.
   */
  public static Component createBasicControls(final int type) {
    final JComboBox deviceComboBox = new JComboBox();

    deviceComboBox.setEditable(false);
    deviceComboBox.setModel(
        new DeviceConfigurationComboBoxModel(
            deviceComboBox, mediaService.getDeviceConfiguration(), type));

    JLabel deviceLabel = new JLabel(getLabelText(type));

    deviceLabel.setDisplayedMnemonic(getDisplayedMnemonic(type));
    deviceLabel.setLabelFor(deviceComboBox);

    final Container devicePanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));

    devicePanel.setMaximumSize(new Dimension(WIDTH, 25));
    devicePanel.add(deviceLabel);
    devicePanel.add(deviceComboBox);

    final JPanel deviceAndPreviewPanel = new TransparentPanel(new BorderLayout());
    int preferredDeviceAndPreviewPanelHeight;

    switch (type) {
      case DeviceConfigurationComboBoxModel.AUDIO:
        preferredDeviceAndPreviewPanelHeight = 225;
        break;
      case DeviceConfigurationComboBoxModel.VIDEO:
        preferredDeviceAndPreviewPanelHeight = 305;
        break;
      default:
        preferredDeviceAndPreviewPanelHeight = 0;
        break;
    }
    if (preferredDeviceAndPreviewPanelHeight > 0)
      deviceAndPreviewPanel.setPreferredSize(
          new Dimension(WIDTH, preferredDeviceAndPreviewPanelHeight));
    deviceAndPreviewPanel.add(devicePanel, BorderLayout.NORTH);

    final ActionListener deviceComboBoxActionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            boolean revalidateAndRepaint = false;

            for (int i = deviceAndPreviewPanel.getComponentCount() - 1; i >= 0; i--) {
              Component c = deviceAndPreviewPanel.getComponent(i);

              if (c != devicePanel) {
                deviceAndPreviewPanel.remove(i);
                revalidateAndRepaint = true;
              }
            }

            Component preview = null;

            if ((deviceComboBox.getSelectedItem() != null) && deviceComboBox.isShowing()) {
              preview =
                  createPreview(type, deviceComboBox, deviceAndPreviewPanel.getPreferredSize());
            }

            if (preview != null) {
              deviceAndPreviewPanel.add(preview, BorderLayout.CENTER);
              revalidateAndRepaint = true;
            }

            if (revalidateAndRepaint) {
              deviceAndPreviewPanel.revalidate();
              deviceAndPreviewPanel.repaint();
            }
          }
        };

    deviceComboBox.addActionListener(deviceComboBoxActionListener);
    /*
     * We have to initialize the controls to reflect the configuration
     * at the time of creating this instance. Additionally, because the
     * video preview will stop when it and its associated controls
     * become unnecessary, we have to restart it when the mentioned
     * controls become necessary again. We'll address the two goals
     * described by pretending there's a selection in the video combo
     * box when the combo box in question becomes displayable.
     */
    deviceComboBox.addHierarchyListener(
        new HierarchyListener() {
          public void hierarchyChanged(HierarchyEvent event) {
            if ((event.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
              SwingUtilities.invokeLater(
                  new Runnable() {
                    public void run() {
                      deviceComboBoxActionListener.actionPerformed(null);
                    }
                  });
            }
          }
        });

    return deviceAndPreviewPanel;
  }
Esempio n. 5
0
  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);
    }
  }