/** * 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()); } }
/** * 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); } } } }
/** * 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); } }