KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.enhydra.shark.corbaclient.workflowadmin.user;
2
3 import java.awt.*;
4 import java.util.*;
5
6
7 import org.omg.WfBase.*;
8 import org.omg.WorkflowModel.*;
9 import org.enhydra.shark.corba.WorkflowService.*;
10 import org.enhydra.shark.corbaclient.*;
11 import org.enhydra.shark.corbaclient.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       NameValue[] 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
75       ArrayList existingUsers=userAccountManagement.getExistingUsers();
76       Map euMap=new HashMap();
77       // make a ID->WfResource map
78
UserGroupAdministration uga=SharkAdmin.getUserGroupAmin();
79       if (lus!=null) {
80          for (int i=0; i<lus.length; i++) {
81             Vector v=new Vector();
82             try {
83                NameValue me=lus[i];
84                String JavaDoc connKey=me.the_name;
85                String JavaDoc uname=me.the_value.extract_wstring();
86                loggedUsers.add(uname);
87                v.add(connKey);
88                v.add(uname);
89                v.add(uga.getUserFirstName(uname));
90                v.add(uga.getUserLastName(uname));
91                v.add(uga.getUserEMailAddress(uname));
92                loggedUsersPanel.addElement(v);
93                loggedUsers.add(uname);
94             } catch (Exception JavaDoc ex) {
95                System.out.println("Something went wrong during retrival of client properties");
96             }
97          }
98       }
99    }
100
101 }
102
103
104
Popular Tags