1 45 package org.exolab.jms.tools.admin; 46 47 import java.awt.event.ActionEvent ; 48 import java.awt.event.ActionListener ; 49 50 import javax.swing.JMenuItem ; 51 import javax.swing.JOptionPane ; 52 import javax.swing.JPopupMenu ; 53 import javax.swing.JTree ; 54 55 56 64 public class OpenJMSUser extends OpenJMSObject { 65 66 73 public OpenJMSUser(String name, JTree tree) { 74 super(name, tree); 75 } 76 77 80 public void update() { 81 } 82 83 89 protected void createCommands() { 90 _commands = new JPopupMenu (); 91 JMenuItem m = new JMenuItem ("Delete user"); 92 m.addActionListener(new ActionListener () { 93 94 public void actionPerformed(ActionEvent evt) { 95 deleteUser(); 96 } 97 } 98 ); 99 _commands.add(m); 100 101 m = new JMenuItem ("Change password"); 102 m.addActionListener(new ActionListener () { 103 104 public void actionPerformed(ActionEvent evt) { 105 changePassword(); 106 } 107 } 108 ); 109 _commands.add(m); 110 } 111 112 118 private static void changePassword() { 119 OpenJMSUser This = (OpenJMSUser) getInstanceSelected(); 120 ChangePasswordDialog.instance().displayChangePassword(This._name); 121 122 if (ChangePasswordDialog.instance().isConfirmed()) { 123 if (AbstractAdminConnection.instance().changePassword( 124 This._name, 125 ChangePasswordDialog.instance().getPassword())) { 126 This.refresh(); 127 } else { 128 JOptionPane.showMessageDialog 129 (_tree, "User already exists", "Create Error", 130 JOptionPane.ERROR_MESSAGE); 131 } 132 } 133 } 134 135 141 private static void deleteUser() { 142 OpenJMSUser This = (OpenJMSUser) getInstanceSelected(); 143 QueryDialog.instance().display 144 ("Are you sure you want to delete \nselected User: " 145 + This._name); 146 if (org.exolab.jms.tools.admin.QueryDialog.instance().isConfirmed()) { 147 if (AbstractAdminConnection.instance().removeUser( 148 This._name)) { 149 This.removeFromParent(); 150 This.refresh(); 151 } else { 152 JOptionPane.showMessageDialog 153 (_tree, "Failed to destroy User", 154 "Destroy User Error", JOptionPane.ERROR_MESSAGE); 155 } 156 } 157 } 158 159 } | Popular Tags |