Example #1
0
 /** Update button enable/disable state according enableCheckBox. */
 private void updateButtonsState() {
   sipProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
   jabberProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
   rtpProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
   ice4jProtocolCheckBox.setEnabled(enableCheckBox.isSelected());
   fileCountField.setEnabled(enableCheckBox.isSelected());
   fileSizeField.setEnabled(enableCheckBox.isSelected());
   fileSizeLabel.setEnabled(enableCheckBox.isSelected());
   fileCountLabel.setEnabled(enableCheckBox.isSelected());
 }
Example #2
0
  /**
   * Create preview component.
   *
   * @param type type
   * @param comboBox the options.
   * @param prefSize the preferred size
   * @return the component.
   */
  private static Component createPreview(int type, final JComboBox comboBox, Dimension prefSize) {
    JComponent preview = null;

    if (type == DeviceConfigurationComboBoxModel.AUDIO) {
      Object selectedItem = comboBox.getSelectedItem();

      if (selectedItem instanceof AudioSystem) {
        AudioSystem audioSystem = (AudioSystem) selectedItem;

        if (!NoneAudioSystem.LOCATOR_PROTOCOL.equalsIgnoreCase(audioSystem.getLocatorProtocol())) {
          preview = new TransparentPanel(new GridBagLayout());
          createAudioSystemControls(audioSystem, preview);
        }
      }
    } else if (type == DeviceConfigurationComboBoxModel.VIDEO) {
      JLabel noPreview =
          new JLabel(
              NeomediaActivator.getResources().getI18NString("impl.media.configform.NO_PREVIEW"));

      noPreview.setHorizontalAlignment(SwingConstants.CENTER);
      noPreview.setVerticalAlignment(SwingConstants.CENTER);

      preview = createVideoContainer(noPreview);
      preview.setPreferredSize(prefSize);

      Object selectedItem = comboBox.getSelectedItem();
      CaptureDeviceInfo device = null;
      if (selectedItem instanceof DeviceConfigurationComboBoxModel.CaptureDevice)
        device = ((DeviceConfigurationComboBoxModel.CaptureDevice) selectedItem).info;

      Exception exception;
      try {
        createVideoPreview(device, preview);
        exception = null;
      } catch (IOException ex) {
        exception = ex;
      } catch (MediaException ex) {
        exception = ex;
      }
      if (exception != null) {
        logger.error("Failed to create preview for device " + device, exception);
        device = null;
      }
    }

    return preview;
  }
Example #3
0
  /** 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);
  }
Example #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;
  }
Example #5
0
  /** 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);
    }
  }