1 package org.ozoneDB.adminGui.feature.account; 9 10 import org.ozoneDB.DxLib.DxCollection; 11 import org.ozoneDB.adminGui.res.Images; 12 import org.ozoneDB.adminGui.main.AdminGui; 13 import org.ozoneDB.adminGui.feature.ActionBar; 14 import org.ozoneDB.adminGui.feature.InfoPanel; 15 import org.ozoneDB.adminGui.feature.account.groups.GroupPanel; 16 import org.ozoneDB.adminGui.feature.account.groups.GroupAccount; 17 18 import javax.swing.*; 19 import java.awt.*; 20 import java.awt.event.ActionListener ; 21 import java.awt.event.ActionEvent ; 22 23 26 class AccountFeatureBar extends ActionBar { 27 private InfoPanel userInfoPanel; 28 29 public AccountFeatureBar(UserInfoPanel userInfoPanel) { 30 this.userInfoPanel = userInfoPanel; 31 addComponents(); 32 } 33 34 protected void addComponents() { 35 36 this.removeAll(); 37 gbc.insets = new Insets(1, 5, 1, 5); 39 gbc.fill = GridBagConstraints.HORIZONTAL; 40 gbc.gridy = 0; 41 42 add(new ActionButton("Users", Images.ACCOUNTS_SHOW_USERS, new UserLister(userInfoPanel), "list users"), gbc); 46 47 gbc.gridy++; 48 add(new ActionButton("new account", Images.ACCOUNTS_CREATE_USER, new AddUserLister(), "create a new account"), gbc); 49 50 gbc.gridy++; 51 add(new ActionButton("Groups", Images.ACCOUNTS_SHOW_GROUPS, new GroupLister(), "list groups"), gbc); 52 53 59 } 62 63 private class AddUserLister implements ActionListener { 64 public void actionPerformed(ActionEvent e) { 65 AddUserDialog dialog = new AddUserDialog(AdminGui.instance(), "Add account"); 66 if (dialog.isInputOK()) { 67 try { 68 String userName = dialog.getUserName(); 69 int userId = dialog.getUserId(); 70 AdminGui.instance().getAdmin().newUser(userName, userId); 71 72 } catch (Exception e1) { 73 userInfoPanel.setDisplay(new JTextArea("Unable to add account: " + e1)); 74 } 75 } 76 } 77 } 78 79 80 private class GroupLister implements ActionListener { 81 public void actionPerformed(ActionEvent event) { 82 System.out.println("list all groups"); 83 userInfoPanel.setDisplay(new GroupPanel()); 84 } 85 } 86 } 87 | Popular Tags |