Beispiel #1
0
  /** Initializes the call button. */
  private void initCallButton() {
    List<ProtocolProviderService> telephonyProviders = CallManager.getTelephonyProviders();

    if (telephonyProviders != null && telephonyProviders.size() > 0) {
      if (callButton.getParent() != null) return;

      callButton.setAlignmentX(JButton.CENTER_ALIGNMENT);

      callButton.setMnemonic(
          GuiActivator.getResources().getI18nMnemonic("service.gui.CALL_CONTACT"));

      buttonPanel.add(callButton);

      callButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              String searchText = parentWindow.getCurrentSearchText();

              if (searchText == null) return;

              CallManager.createCall(searchText, callButton);
            }
          });
    } else {
      buttonPanel.remove(callButton);
    }
  }
  /**
   * 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;
  }
Beispiel #3
0
  /**
   * Handles the <tt>ActionEvent</tt> which occurred when user clicks the Search button.
   *
   * @param e the <tt>ActionEvent</tt> that notified us of the button click
   */
  public void actionPerformed(ActionEvent e) {
    JButton button = (JButton) e.getSource();
    String buttonName = button.getName();

    if (buttonName.equalsIgnoreCase("search")) {
      historyWindow.showHistoryByKeyword(searchTextField.getText());
    }
  }
Beispiel #4
0
  /** Reloads button resources. */
  public void loadSkin() {
    addButton.setIcon(
        GuiActivator.getResources().getImage("service.gui.icons.ADD_CONTACT_16x16_ICON"));
    callButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.CALL_16x16_ICON"));

    if (smsButton != null)
      smsButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.SMS_BUTTON_ICON"));
  }
  /** Enables(if a skin <tt>Bundle</tt> is selected) or disables the remove button. */
  private void enableDisableButton() {
    Object tmp = skinSelector.getSelectedItem();

    if (tmp != null) {
      if (tmp instanceof Bundle) {
        rmButton.setEnabled(true);

        return;
      }
    }
    rmButton.setEnabled(false);
  }
  /**
   * Handles the <tt>ActionEvent</tt> triggered when one of the buttons is clicked. When "Login"
   * button is choosen installs a new account from the user input and logs in.
   *
   * @param evt the action event that has just occurred.
   */
  public void actionPerformed(ActionEvent evt) {
    JButton button = (JButton) evt.getSource();
    String buttonName = button.getName();

    if (buttonName.equals("ok")) {
      GuiActivator.getUIService()
          .getConferenceChatManager()
          .joinChatRoom(
              chatRoom, idValue.getText(), new String(passwdField.getPassword()).getBytes());
    }

    this.dispose();
  }
  /**
   * Calls the given treeNode.
   *
   * @param treeNode the <tt>TreeNode</tt> to call
   */
  private void call(TreeNode treeNode, JButton button, boolean isVideo, boolean isDesktopSharing) {
    if (!(treeNode instanceof ContactNode)) return;

    UIContact contactDescriptor = ((ContactNode) treeNode).getContactDescriptor();

    Point location = new Point(button.getX(), button.getY() + button.getHeight());

    SwingUtilities.convertPointToScreen(location, treeContactList);

    location.y = location.y + treeContactList.getPathBounds(treeContactList.getSelectionPath()).y;
    location.x += 8;
    location.y -= 8;

    CallManager.call(contactDescriptor, isVideo, isDesktopSharing, treeContactList, location);
  }
Beispiel #8
0
  private void initAddContactButton() {
    addButton.setAlignmentX(JButton.CENTER_ALIGNMENT);

    addButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.ADD_CONTACT"));

    buttonPanel.add(addButton);

    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            AddContactDialog dialog = new AddContactDialog(parentWindow);

            dialog.setContactAddress(parentWindow.getCurrentSearchText());
            dialog.setVisible(true);
          }
        });
  }
  /** 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);
  }
Beispiel #10
0
  /**
   * Updates the text area to take into account the new search text.
   *
   * @param searchText the search text to update
   */
  private void updateTextArea(String searchText) {
    if (callButton.getParent() != null) {
      textArea.setText(
          GuiActivator.getResources()
              .getI18NString(
                  "service.gui.NO_CONTACTS_FOUND", new String[] {'"' + searchText + '"'}));

      this.revalidate();
      this.repaint();
    }
  }
Beispiel #11
0
  /** Constructs the <tt>SearchPanel</tt>. */
  private void init() {
    String searchString = GuiActivator.getResources().getI18NString("service.gui.SEARCH");
    JLabel searchLabel = new JLabel(searchString + ": ");

    searchButton =
        new JButton(searchString, new ImageIcon(ImageLoader.getImage(ImageLoader.SEARCH_ICON)));

    this.searchTextField.getDocument().addDocumentListener(this);

    this.add(searchLabel, BorderLayout.WEST);
    this.add(searchTextField, BorderLayout.CENTER);

    searchButton.setName("search");
    searchButton.setMnemonic(GuiActivator.getResources().getI18nMnemonic("service.gui.SEARCH"));

    searchButton.addActionListener(this);

    this.historyWindow.getRootPane().setDefaultButton(searchButton);

    this.add(searchButton, BorderLayout.EAST);
  }
Beispiel #12
0
  /** Initializes the call button. */
  private void initSMSButton() {
    if (!parentWindow.hasOperationSet(OperationSetSmsMessaging.class)) return;

    smsButton = new JButton(GuiActivator.getResources().getI18NString("service.gui.SEND_SMS"));

    smsButton.setIcon(GuiActivator.getResources().getImage("service.gui.icons.SMS_BUTTON_ICON"));

    buttonPanel.add(smsButton);

    smsButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            final String searchText = parentWindow.getCurrentSearchText();

            if (searchText == null) return;

            SMSManager.sendSMS(smsButton, searchText);
          }
        });
  }
  /**
   * Resets the rollover state of all rollover components in the current cell except the component
   * given as a parameter.
   *
   * @param excludeComponent the component to exclude from the reset
   */
  public void resetRolloverState(Component excludeComponent) {
    if (!chatButton.equals(excludeComponent)) chatButton.getModel().setRollover(false);

    if (!callButton.equals(excludeComponent)) callButton.getModel().setRollover(false);

    if (!callVideoButton.equals(excludeComponent)) callVideoButton.getModel().setRollover(false);

    if (!desktopSharingButton.equals(excludeComponent))
      desktopSharingButton.getModel().setRollover(false);

    if (!addContactButton.equals(excludeComponent)) addContactButton.getModel().setRollover(false);

    if (customActionButtons != null) {
      Iterator<JButton> buttonsIter = customActionButtons.iterator();
      while (buttonsIter.hasNext()) {
        JButton button = buttonsIter.next();

        if (!button.equals(excludeComponent)) button.getModel().setRollover(false);
      }
    }

    if (customActionButtonsUIGroup != null) {
      Iterator<JButton> buttonsIter = customActionButtonsUIGroup.iterator();
      while (buttonsIter.hasNext()) {
        JButton button = buttonsIter.next();

        if (!button.equals(excludeComponent)) button.getModel().setRollover(false);
      }
    }
  }
  /**
   * Handles buttons action events.
   *
   * @param evt the <tt>ActionEvent</tt> that notified us
   */
  public void actionPerformed(ActionEvent evt) {
    JButton sourceButton = (JButton) evt.getSource();

    if (sourceButton.equals(openFileButton)) {
      this.openFile(downloadFile);
    } else if (sourceButton.equals(openFolderButton)) {
      try {
        File downloadDir = GuiActivator.getFileAccessService().getDefaultDownloadDirectory();

        GuiActivator.getDesktopService().open(downloadDir);
      } catch (IllegalArgumentException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_DOES_NOT_EXIST"));
      } catch (NullPointerException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_DOES_NOT_EXIST"));
      } catch (UnsupportedOperationException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FILE_OPEN_NOT_SUPPORTED"));
      } catch (SecurityException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_OPEN_NO_PERMISSION"));
      } catch (IOException e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open folder.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_OPEN_NO_APPLICATION"));
      } catch (Exception e) {
        if (logger.isDebugEnabled()) logger.debug("Unable to open file.", e);

        this.showErrorMessage(resources.getI18NString("service.gui.FOLDER_OPEN_FAILED"));
      }
    } else if (sourceButton.equals(cancelButton)) {
      if (fileTransfer != null) fileTransfer.cancel();
    }
  }
  /** Resets the rollover state of all rollover components in the current cell. */
  public void resetRolloverState() {
    chatButton.getModel().setRollover(false);
    callButton.getModel().setRollover(false);
    callVideoButton.getModel().setRollover(false);
    desktopSharingButton.getModel().setRollover(false);
    addContactButton.getModel().setRollover(false);

    if (customActionButtons != null) {
      Iterator<JButton> buttonsIter = customActionButtons.iterator();
      while (buttonsIter.hasNext()) {
        JButton button = buttonsIter.next();
        button.getModel().setRollover(false);
      }
    }

    if (customActionButtonsUIGroup != null) {
      Iterator<JButton> buttonsIter = customActionButtonsUIGroup.iterator();
      while (buttonsIter.hasNext()) {
        JButton button = buttonsIter.next();
        button.getModel().setRollover(false);
      }
    }
  }
Beispiel #16
0
  /**
   * Creates the <tt>UnknownContactPanel</tt> by specifying the parent window.
   *
   * @param window the parent window
   */
  public UnknownContactPanel(MainFrame window) {
    super(new BorderLayout());

    this.parentWindow = window;

    TransparentPanel mainPanel = new TransparentPanel(new BorderLayout());

    this.add(mainPanel, BorderLayout.NORTH);

    if (!ConfigurationUtils.isAddContactDisabled()) {
      initAddContactButton();
    }

    initCallButton();

    initSMSButton();

    initTextArea();
    mainPanel.add(textArea, BorderLayout.CENTER);

    if (callButton.getParent() != null) {
      textArea.setText(
          GuiActivator.getResources()
              .getI18NString(
                  "service.gui.NO_CONTACTS_FOUND",
                  new String[] {'"' + parentWindow.getCurrentSearchText() + '"'}));
    } else {
      textArea.setText(
          GuiActivator.getResources().getI18NString("service.gui.NO_CONTACTS_FOUND_SHORT"));
    }

    if (buttonPanel.getComponentCount() > 0) {
      TransparentPanel southPanel = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));
      southPanel.add(buttonPanel);

      mainPanel.add(southPanel, BorderLayout.SOUTH);
    }

    loadSkin();
  }
Beispiel #17
0
  /** 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);
  }
Beispiel #18
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);
    }
  }
Beispiel #19
0
  /** 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);
  }
 /**
  * Automatically press the cancel button when this dialog has been escaped.
  *
  * @param escaped indicates if this dialog has been closed by pressing the ESC key
  */
 @Override
 protected void close(boolean escaped) {
   if (escaped) cancelButton.doClick();
 }
Beispiel #21
0
 /** Reloads search button icon. */
 public void loadSkin() {
   searchButton.setIcon(new ImageIcon(ImageLoader.getImage(ImageLoader.SEARCH_ICON)));
 }
Beispiel #22
0
  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);
  }
Beispiel #23
0
 /** Clicks the call contact button in order to call the unknown contact. */
 public void startCall() {
   callButton.doClick();
 }
Beispiel #24
0
 /** Clicks the add contact button in order to add the unknown contact to the contact list. */
 public void addUnknownContact() {
   addButton.doClick();
 }
Beispiel #25
0
  /**
   * 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));
  }
  /**
   * Saves all configuration settings when the "Save" button is pressed.
   *
   * @param e the <tt>ActionEvent</tt> that notified us of the button action
   */
  public void actionPerformed(ActionEvent e) {
    JButton button = (JButton) e.getSource();

    if (button.equals(saveButton)) {
      Iterator<ChatRoomConfigurationFormField> configurationSet = configForm.getConfigurationSet();

      while (configurationSet.hasNext()) {
        ChatRoomConfigurationFormField formField = configurationSet.next();

        // If the field is of type fixed the user could not change it,
        // so we skip it.
        if (formField.getType().equals(ChatRoomConfigurationFormField.TYPE_TEXT_FIXED)) continue;

        JComponent c = uiFieldsTable.get(formField.getName());

        if (c instanceof JTextComponent) {
          String newValue = ((JTextComponent) c).getText();

          if (formField.getType().equals(ChatRoomConfigurationFormField.TYPE_ID_MULTI)) {
            // extract values
            StringTokenizer idTokens =
                new StringTokenizer(newValue, System.getProperty("line.separator"));
            while (idTokens.hasMoreTokens()) {
              formField.addValue(idTokens.nextToken());
            }
          } else formField.addValue(newValue);
        } else if (c instanceof AbstractButton) {
          boolean isSelected = ((AbstractButton) c).isSelected();

          formField.addValue(isSelected);
        } else if (c instanceof JComboBox) {
          Object selectedObject = ((JComboBox) c).getSelectedItem();

          formField.addValue(selectedObject);
        } else if (c instanceof JPanel) {
          Component[] components = c.getComponents();

          for (Component comp : components) {
            if (!(comp instanceof JCheckBox)) continue;

            JCheckBox checkBox = (JCheckBox) comp;

            formField.addValue(checkBox.getText());
          }
        }
      }

      new Thread() {
        @Override
        public void run() {
          try {
            configForm.submit();
          } catch (Exception e) {
            new ErrorDialog(
                    ChatRoomConfigurationWindow.this,
                    GuiActivator.getResources().getI18NString("service.gui.ERROR"),
                    GuiActivator.getResources()
                        .getI18NString("service.gui.CHAT_ROOM_CONFIGURATION_SUBMIT_FAILED"),
                    e)
                .showDialog();
          }
        }
      }.start();
    }

    this.dispose();
  }