コード例 #1
0
ファイル: SelectAvatarMenu.java プロジェクト: Echo-tcx/Jitsi
  /**
   * Action performed on various action links(buttons).
   *
   * @param e the action.
   */
  public void actionPerformed(ActionEvent e) {
    JButton src = (JButton) e.getSource();

    if (src instanceof SIPCommButton) {
      // Load image
      int index = Integer.parseInt(src.getName());
      BufferedImage image = AvatarStackManager.loadImage(index);

      // Set the new image
      setNewImage(image);
    } else if (src.getName().equals("chooseButton")) {
      // Open the image picker
      Image currentImage = this.avatarImage.getAvatar();

      ImagePickerDialog dialog = new ImagePickerDialog(96, 96);

      byte[] bimage = dialog.showDialog(currentImage);

      if (bimage == null) return;

      // New image
      BufferedImage image = ImageUtils.getBufferedImage(new ImageIcon(bimage).getImage());

      // Store image
      if (this.nextImageIndex == MAX_STORED_IMAGES) {
        // No more place to store images
        // Pop the first element (index 0)
        AvatarStackManager.popFirstImage(MAX_STORED_IMAGES);

        this.nextImageIndex = MAX_STORED_IMAGES - 1;
      }

      // Store the new image on hard drive
      AvatarStackManager.storeImage(image, this.nextImageIndex);

      // Inform protocols about the new image
      setNewImage(image);
    } else if (src.getName().equals("removeButton")) {
      // Removes the current photo.
      setNewImage(null);
    } else if (src.getName().equals("clearButton")) {
      clearRecentImages();
    }

    setVisible(false);
  }
コード例 #2
0
ファイル: SearchPanel.java プロジェクト: 0xbb/jitsi
  /**
   * 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());
    }
  }
コード例 #3
0
 public void actionPerformed(ActionEvent event) {
   JButton button = (JButton) event.getSource();
   String location = button.getName().substring(8);
   int row = Integer.parseInt(location.substring(0, 1));
   int column = Integer.parseInt(location.substring(1, 2));
   model.markBoard(row, column);
   button.setText(model.checkSpot(row, column));
   checkForWin(row, column);
 }
コード例 #4
0
  /**
   * Handles the <tt>ActionEvent</tt>. In order to change the status message with the new one calls
   * the <tt>PublishStatusMessageThread</tt>.
   *
   * @param e the event that notified us of the action
   */
  public void actionPerformed(ActionEvent e) {
    JButton button = (JButton) e.getSource();
    String name = button.getName();

    if (name.equals("ok")) {
      new PublishStatusMessageThread(messageTextField.getText()).start();
    }

    this.dispose();
  }
コード例 #5
0
  /**
   * 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();
  }
コード例 #6
0
  /**
   * Handles the <tt>ActionEvent</tt>. In order to rename the contact invokes the <code>
   * renameMetaContact</code> method of the current <tt>MetaContactListService</tt>.
   */
  public void actionPerformed(ActionEvent e) {
    JButton button = (JButton) e.getSource();
    String name = button.getName();

    if (name.equals("rename")) {
      if (metaContact != null) {
        new Thread() {
          public void run() {
            clist.renameMetaContact(metaContact, renameContactPanel.getNewName());
          }
        }.start();
      }
    }
    this.dispose();
  }
コード例 #7
0
  /**
   * Handles the <tt>ActionEvent</tt> triggered when one of the buttons is clicked. When "Login"
   * button is chosen 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 ("ok".equals(buttonName)) {
      if (uinValue instanceof JLabel) userName = ((JLabel) uinValue).getText();
      else if (uinValue instanceof JTextField) userName = ((JTextField) uinValue).getText();

      password = passwdField.getPassword();
      isRememberPassword = rememberPassCheckBox.isSelected();
    } else {
      isCanceled = true;
    }

    // release the caller that opened the window
    buttonClicked = true;
    synchronized (lock) {
      lock.notify();
    }

    this.dispose();
  }
コード例 #8
0
  /**
   * Réagit au clique de la souris sur un bouton
   *
   * @param e L'ActionEvent généré
   */
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() instanceof JButton) {
      JButton b = (JButton) e.getSource();
      if (b.getName() == "statTab") { // Si on clique sur l'onglet statistiques
        cartes.show(panneau, "statistiques");
      } else if (b.getName() == "payTab") { // Si on clique sur l'onglet de paiement
        cartes.show(panneau, "paiement");
      } else if (b.getName() == "loginButton") { // Si on clique sur le bonton de login
        char[] input = passTextField.getPassword();
        String pass = new String("root"); // Le mot de passe
        if (pass.equals(new String(input))) {
          cartes.show(panneau, "paiement");
          loginLabel.setText("");
        } else loginLabel.setText("Mot de passe incorrect");

        Arrays.fill(input, '0');
        passTextField.selectAll();
      } else if (b.getName() == "annuler") { // Si clique sur annuler
        // On réserte la sélection et on déselectionne les tables
        ControleurTables.deleteSelection();
        this.tableCounter = 0;
        this.payTextField.setText("");
        this.valider.setEnabled(false);
        this.valider.setBackground(Color.GRAY);
      } else if (b.getName() == "valider") { // Si on clique sur valider

        // On récupère la date
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.SECOND, (int) this.difTemps);
        // On récupère le mode de paiement sélectionné
        String type = new String("carte bleue");
        if (especes.isSelected()) {
          type = "especes";
        } else if (cheque.isSelected()) {
          type = "cheque";
        }
        try { // On verifie que le prix rentré est correct
          // On met tout dans le meme try pour annuler l'insertion de la commande dans la bdd en cas
          // d'erreur
          float prix = Float.parseFloat(payTextField.getText());
          ModelePaiement mP = new ModelePaiement();
          mP.insert(cal, prix, type);
          // On recupère la selection
          ArrayList<Table> tab = ControleurTables.getSelection();
          // On met toutes les tables à laver
          for (int i = 0; i < tab.size(); i++) {
            tab.get(i).setStatut(Table.ALAVER);
            tab.get(i).setNom(null);
          }
          // On déselectionne les tables
          ControleurTables.deleteSelection();
          this.tableCounter = 0;
          this.payTextField.setText("");
          this.valider.setEnabled(false);
          this.valider.setBackground(Color.GRAY);
          // On insère le paiement dans la bdd
          modeleTable.updateTables(this.tables);
        } catch (NumberFormatException nfe) {
          JOptionPane.showMessageDialog(
              null, "Veuillez entrez un rpix valide.", "Erreur prix", JOptionPane.ERROR_MESSAGE);
        }
      } else if (b.getName() == "trier") { // Si on appuie sur trier
        float ca = -1;
        ModelePaiement mP = new ModelePaiement();
        if (service.isSelected()) { // Si on selection le chiffre d'affaire par service
          ca =
              mP.getCAService(
                  (String)
                      serviceComboBox
                          .getSelectedItem()); // On sélectonne le chiffre d'affaire en focntion du
                                               // service

        } else if (date.isSelected()) { // Si on selection le chiffre d'affaire par date
          try { // On verifie que la date est bien valide
            Calendar cal = Calendar.getInstance();
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
            cal.setTime(sdf.parse(dateTextField.getText()));
            ca = mP.getCADate(cal); // On va chercher le chiffre d'affaire en fonction de la date
          } catch (Exception npe) {
            JOptionPane.showMessageDialog(
                null,
                "Veuillez entrez une date de la forme 03/06/2012.",
                "Erreur date",
                JOptionPane.ERROR_MESSAGE);
          }
        }

        if (ca > -1) { // Si on a récupérer un chiffre d'affaire
          chiffreAffaire.setText("Chiffre d'affaire : " + Float.toString(ca));
        }
      } else if (b.getName() == "option") { // Si on clique sur option
        String strDate =
            JOptionPane.showInputDialog(null, "Réglage de temps (ex: 03/06/1996 15:06) ", null);

        try {
          Calendar cal = Calendar.getInstance();
          Calendar now = Calendar.getInstance();

          SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");
          cal.setTime(sdf.parse(strDate));
          difTemps =
              (int)
                  ((cal.getTimeInMillis() - now.getTimeInMillis())
                      / 1000); // Transformation en secondes
          if ((cal.getTimeInMillis() - now.getTimeInMillis()) % 1000 > 0) {
            difTemps++;
          }
        } catch (Exception exep) {
          JOptionPane.showMessageDialog(
              null,
              "Vous devez entrer une date valide (ex: 03/06/1996 15:06).",
              "Date invalide",
              JOptionPane.ERROR_MESSAGE);
        }
      }
    }
  }
コード例 #9
0
ファイル: CallManager.java プロジェクト: ymatlashenko/olyo
  /**
   * Handles the <tt>ActionEvent</tt> generated when user presses one of the buttons in this panel.
   */
  public void actionPerformed(ActionEvent evt) {
    JButton button = (JButton) evt.getSource();
    String buttonName = button.getName();

    if (buttonName.equals("call")) {
      Component selectedPanel = mainFrame.getSelectedTab();

      // call button is pressed over an already open call panel
      if (selectedPanel != null
          && selectedPanel instanceof CallPanel
          && ((CallPanel) selectedPanel).getCall().getCallState()
              == CallState.CALL_INITIALIZATION) {

        NotificationManager.stopSound(NotificationManager.BUSY_CALL);
        NotificationManager.stopSound(NotificationManager.INCOMING_CALL);

        CallPanel callPanel = (CallPanel) selectedPanel;

        Iterator participantPanels = callPanel.getParticipantsPanels();

        while (participantPanels.hasNext()) {
          CallParticipantPanel panel = (CallParticipantPanel) participantPanels.next();

          panel.setState("Connecting");
        }

        Call call = callPanel.getCall();

        answerCall(call);
      }
      // call button is pressed over the call list
      else if (selectedPanel != null
          && selectedPanel instanceof CallListPanel
          && ((CallListPanel) selectedPanel).getCallList().getSelectedIndex() != -1) {

        CallListPanel callListPanel = (CallListPanel) selectedPanel;

        GuiCallParticipantRecord callRecord =
            (GuiCallParticipantRecord) callListPanel.getCallList().getSelectedValue();

        String stringContact = callRecord.getParticipantName();

        createCall(stringContact);
      }
      // call button is pressed over the contact list
      else if (selectedPanel != null && selectedPanel instanceof ContactListPanel) {
        // call button is pressed when a meta contact is selected
        if (isCallMetaContact) {
          Object[] selectedContacts =
              mainFrame.getContactListPanel().getContactList().getSelectedValues();

          Vector telephonyContacts = new Vector();

          for (int i = 0; i < selectedContacts.length; i++) {

            Object o = selectedContacts[i];

            if (o instanceof MetaContact) {

              Contact contact =
                  ((MetaContact) o).getDefaultContact(OperationSetBasicTelephony.class);

              if (contact != null) telephonyContacts.add(contact);
              else {
                new ErrorDialog(
                        this.mainFrame,
                        Messages.getI18NString("warning").getText(),
                        Messages.getI18NString(
                                "contactNotSupportingTelephony",
                                new String[] {((MetaContact) o).getDisplayName()})
                            .getText())
                    .showDialog();
              }
            }
          }

          if (telephonyContacts.size() > 0) createCall(telephonyContacts);

        } else if (!phoneNumberCombo.isComboFieldEmpty()) {

          // if no contact is selected checks if the user has chosen
          // or has
          // writen something in the phone combo box

          String stringContact = phoneNumberCombo.getEditor().getItem().toString();

          createCall(stringContact);
        }
      } else if (selectedPanel != null && selectedPanel instanceof DialPanel) {
        String stringContact = phoneNumberCombo.getEditor().getItem().toString();
        createCall(stringContact);
      }
    } else if (buttonName.equalsIgnoreCase("hangup")) {
      Component selectedPanel = this.mainFrame.getSelectedTab();

      if (selectedPanel != null && selectedPanel instanceof CallPanel) {

        NotificationManager.stopSound(NotificationManager.BUSY_CALL);
        NotificationManager.stopSound(NotificationManager.INCOMING_CALL);
        NotificationManager.stopSound(NotificationManager.OUTGOING_CALL);

        CallPanel callPanel = (CallPanel) selectedPanel;

        Call call = callPanel.getCall();

        if (removeCallTimers.containsKey(callPanel)) {
          ((Timer) removeCallTimers.get(callPanel)).stop();
          removeCallTimers.remove(callPanel);
        }

        removeCallPanel(callPanel);

        if (call != null) {
          ProtocolProviderService pps = call.getProtocolProvider();

          OperationSetBasicTelephony telephony = mainFrame.getTelephonyOpSet(pps);

          Iterator participants = call.getCallParticipants();

          while (participants.hasNext()) {
            try {
              // now we hang up the first call participant in the
              // call
              telephony.hangupCallParticipant((CallParticipant) participants.next());
            } catch (OperationFailedException e) {
              logger.error("Hang up was not successful: " + e);
            }
          }
        }
      }
    } else if (buttonName.equalsIgnoreCase("minimize")) {
      JCheckBoxMenuItem hideCallPanelItem =
          mainFrame.getMainMenu().getViewMenu().getHideCallPanelItem();

      if (!hideCallPanelItem.isSelected()) hideCallPanelItem.setSelected(true);

      this.setCallPanelVisible(false);
    } else if (buttonName.equalsIgnoreCase("restore")) {

      JCheckBoxMenuItem hideCallPanelItem =
          mainFrame.getMainMenu().getViewMenu().getHideCallPanelItem();

      if (hideCallPanelItem.isSelected()) hideCallPanelItem.setSelected(false);

      this.setCallPanelVisible(true);
    }
  }