KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > swingclient > workflowadmin > user > LoggedUsersManagement


1 package org.enhydra.shark.swingclient.workflowadmin.user;
2
3 import java.awt.*;
4 import java.util.*;
5
6
7
8
9 import org.enhydra.shark.api.client.wfservice.*;
10 import org.enhydra.shark.swingclient.*;
11 import org.enhydra.shark.swingclient.workflowadmin.*;
12
13 /**
14  * Implements the user interface and program logic to view
15  * the logged users.
16  *
17  * @author Sasa Bojanic
18  * @version 1.0
19  */

20 public class LoggedUsersManagement extends ActionPanel {
21
22    private SharkAdmin workflowAdmin;
23    private UserAccountManagement userAccountManagement;
24
25    private TablePanel loggedUsersPanel;
26    private Set loggedUsers=new HashSet();
27
28
29    public LoggedUsersManagement (SharkAdmin wa,UserAccountManagement uam) {
30       super();
31
32       this.workflowAdmin=wa;
33       this.userAccountManagement=uam;
34
35       super.init();
36    }
37
38    protected void createActions () {}
39
40    protected Component createCenterComponent() {
41       Vector columnNames=new Vector();
42       columnNames.add(ResourceManager.getLanguageDependentString("ConnectionIdKey"));
43       columnNames.add(ResourceManager.getLanguageDependentString("UsernameKey"));
44       columnNames.add(ResourceManager.getLanguageDependentString("FirstNameKey"));
45       columnNames.add(ResourceManager.getLanguageDependentString("LastNameKey"));
46       columnNames.add(ResourceManager.getLanguageDependentString("EmailAddressKey"));
47
48       loggedUsersPanel=new TablePanel(columnNames, true);
49       return loggedUsersPanel;
50    }
51
52    public boolean isLogged (String JavaDoc username) {
53       return loggedUsers.contains(username);
54    }
55
56    public void clear () {
57       loggedUsers.clear();
58       loggedUsersPanel.removeAll();
59    }
60
61    public synchronized void refresh (boolean mandatoryRefreshing) {
62       if (!(mandatoryRefreshing || isShowing())) return;
63
64       Map lus=null;
65       try {
66          lus=SharkAdmin.getExecAmin().getLoggedUsers();
67       } catch (Exception JavaDoc ex) {
68          System.out.println("Something went wrong during retrival of clients from engine");
69          return;
70       }
71
72       loggedUsersPanel.removeAll();
73       loggedUsers.clear();
74       Iterator it=lus.entrySet().iterator();
75       UserGroupAdministration uga=SharkAdmin.getUserGroupAmin();
76       while (it.hasNext()) {
77          Vector v=new Vector();
78          try {
79             Map.Entry me=(Map.Entry)it.next();
80             String JavaDoc connKey=(String JavaDoc)me.getKey();
81             String JavaDoc uname=(String JavaDoc)me.getValue();
82             v.add(connKey);
83             v.add(uname);
84             v.add(uga.getUserFirstName(uname));
85             v.add(uga.getUserLastName(uname));
86             v.add(uga.getUserEMailAddress(uname));
87             loggedUsersPanel.addElement(v);
88             loggedUsers.add(uname);
89          } catch (Exception JavaDoc ex) {
90             System.out.println("Something went wrong during retrival of client properties");
91          }
92       }
93    }
94
95 }
96
Popular Tags