1 package org.ozoneDB.adminGui.feature.account.users; 8 9 import java.awt.BorderLayout ; 10 import javax.swing.JDialog ; 11 12 import org.ozoneDB.adminGui.widget.ButtonPanel; 13 import org.ozoneDB.adminGui.widget.ButtonPanelListener; 14 import org.ozoneDB.adminGui.main.AdminGui; 15 16 17 26 28 public class WorkUserDialog extends JDialog implements ButtonPanelListener { 29 30 31 private UserAccount parent = null; 32 33 private WorkUserPanel userPane = null; 34 35 private String [] button = {"OK", "Cancel"}; 36 37 private boolean ok = false; 38 39 private String name = ""; 40 41 private String password = ""; 42 43 44 47 public WorkUserDialog(UserAccount parent) { 48 super(AdminGui.instance(), "Create User", true); 49 this.parent = parent; 50 51 try { 52 init(); 53 this.setSize(300, 200); 54 } catch (Exception e) { 55 e.printStackTrace(); 56 } 57 } 58 59 62 private void init() throws Exception { 63 this.setResizable(false); 65 this.setLocationRelativeTo(AdminGui.instance()); 66 this.getContentPane().setLayout(new BorderLayout ()); 67 68 userPane = new WorkUserPanel(); 70 71 ButtonPanel buttonPane = new ButtonPanel(this.button); 72 buttonPane.addConnectionListener(this); 73 74 this.getContentPane().add(userPane, BorderLayout.CENTER); 76 this.getContentPane().add(buttonPane, BorderLayout.SOUTH); 77 } 78 79 84 public void buttonExecute(String buttonName) { 85 if (button[0].equals(buttonName)) 87 collectUserInfo(); 88 89 else 91 this.hide(); 92 } 93 94 97 private void collectUserInfo() { 98 this.name = this.userPane.getUserName().trim(); 99 this.password = this.userPane.getUserPassword().trim(); 100 101 if (this.name.equals("") | this.name == null) 103 this.ok = false; 104 else { 105 this.ok = true; 106 107 if (this.password.equals("") | this.password == null) 109 this.password = name; 110 } 111 112 this.hide(); 113 } 114 115 120 public String getName() { 121 return this.name; 122 } 123 124 129 public String getPassword() { 130 return this.password; 131 } 132 133 139 public boolean isOK() { 140 return this.ok; 141 } 142 143 } | Popular Tags |