KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > adminGui > feature > account > AccountFeatureBar


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: AccountFeatureBar.java,v 1.1 2003/11/09 15:47:32 per_nyfelt Exp $
8
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 JavaDoc;
21 import java.awt.event.ActionEvent JavaDoc;
22
23 /**
24  * @author Per Nyfelt
25  */

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.gridx = GridBagConstraints.REMAINDER;
38
gbc.insets = new Insets(1, 5, 1, 5);
39         gbc.fill = GridBagConstraints.HORIZONTAL;
40         gbc.gridy = 0;
41
42         // Add label
43
//gbc.anchor = GridBagConstraints.SOUTHWEST;
44
//gbc.weighty = .3;
45
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         // Add component
54
//gbc.anchor = GridBagConstraints.NORTHWEST;
55
//gbc.weighty = 0;
56
//JTextField textField = new JTextField(10);
57
//add(textField, gbc);
58

59         // Add components to componentMap
60
//components.put(propName, textField);
61
}
62
63     private class AddUserLister implements ActionListener JavaDoc {
64         public void actionPerformed(ActionEvent JavaDoc e) {
65             AddUserDialog dialog = new AddUserDialog(AdminGui.instance(), "Add account");
66             if (dialog.isInputOK()) {
67                 try {
68                     String JavaDoc userName = dialog.getUserName();
69                     int userId = dialog.getUserId();
70                     AdminGui.instance().getAdmin().newUser(userName, userId);
71
72                 } catch (Exception JavaDoc e1) {
73                     userInfoPanel.setDisplay(new JTextArea("Unable to add account: " + e1));
74                 }
75             }
76         }
77     }
78
79
80     private class GroupLister implements ActionListener JavaDoc {
81         public void actionPerformed(ActionEvent JavaDoc event) {
82             System.out.println("list all groups");
83             userInfoPanel.setDisplay(new GroupPanel());
84         }
85     }
86 }
87
Popular Tags