/* * Jeti, a Java Jabber client, Copyright (C) 2001 E.S. de Boer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * For questions, comments etc, * use the website at http://jeti.jabberstudio.org * or mail/IM me at jeti@jabber.org * * created 24-4-2005 */ package nu.fw.jeti.ui; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import javax.swing.*; import nu.fw.jeti.jabber.Backend; import nu.fw.jeti.jabber.JID; import nu.fw.jeti.jabber.elements.IQRegister; import nu.fw.jeti.jabber.elements.InfoQuery; import nu.fw.jeti.util.I18N; import nu.fw.jeti.util.Utils; /** * @author E.S. de Boer */ public class ChangePassword extends JDialog { //JPanel panel1 = new JPanel(); private Box panel1 = Box.createVerticalBox(); private JLabel jLabel1 = new JLabel(); private JPasswordField txtOldPassword = new JPasswordField(); private JLabel jLabel2 = new JLabel(); private JPasswordField txtNewPassword1 = new JPasswordField(); private JPasswordField txtNewPassword2 = new JPasswordField(); private JLabel jLabel3 = new JLabel(); private JPanel jPanel1 = new JPanel(); private JButton btnCancel = new JButton(); private JButton btnOK = new JButton(); private Backend backend; public ChangePassword(Backend backend) { super(backend.getMainFrame(), I18N.gettext("main.ChangePassword.Change_Password"), false); this.backend = backend; jbInit(); pack(); setLocationRelativeTo(backend.getMainFrame()); } void jbInit() { I18N.setTextAndMnemonic("main.ChangePassword.Old_Password",jLabel1); txtOldPassword.setHorizontalAlignment(SwingConstants.LEADING); txtNewPassword1.setHorizontalAlignment(SwingConstants.LEFT); txtNewPassword2.setHorizontalAlignment(SwingConstants.LEFT); jPanel1.setAlignmentX(0.0f); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); panel1.add(Box.createHorizontalGlue()); I18N.setTextAndMnemonic("main.ChangePassword.New_Password",jLabel2); jLabel2.setLabelFor(txtNewPassword1); jLabel3.setHorizontalAlignment(SwingConstants.LEFT); I18N.setTextAndMnemonic("main.ChangePassword.New_Password",jLabel3); jLabel3.setLabelFor(txtNewPassword2); jLabel1.setHorizontalAlignment(SwingConstants.LEFT); Action cancelAction = new AbstractAction(I18N.gettext("Cancel")) { public void actionPerformed(ActionEvent e) { dispose(); } }; Utils.addCancelButton(this, btnCancel, cancelAction); btnOK.setText(I18N.gettext("OK")); btnOK.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { btnOK_actionPerformed(e); } }); getContentPane().add(panel1, BorderLayout.CENTER); panel1.add(jLabel1); panel1.add(txtOldPassword); panel1.add(jLabel2); panel1.add(txtNewPassword1); panel1.add(jLabel3); panel1.add(txtNewPassword2); panel1.add(jPanel1); jPanel1.add(btnOK); jPanel1.add(btnCancel); } void btnOK_actionPerformed(ActionEvent e) { if(txtNewPassword1.getText().equals(" ") || !txtNewPassword1.getText().equals(txtNewPassword2.getText())) { JOptionPane.showMessageDialog(this, I18N.gettext("main.ChangePassword.Password_not_equal")); } else { if(backend.isPasswordValid(txtOldPassword.getText())) { //TODO add iq listener that changes password in profile if set backend.send(new InfoQuery(new JID(backend.getMyJID().getDomain()) ,"set",new IQRegister( backend.getMyJID().getUser(),txtNewPassword1.getText()))); this.dispose(); } } } } /* * Overrides for emacs * Local variables: * tab-width: 4 * End: */