1 package org.enhydra.shark.corbaclient.workflowadmin.user; 2 3 import java.awt.*; 4 import java.util.*; 5 6 import javax.swing.*; 7 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 import org.enhydra.shark.corbaclient.workflowadmin.user.actions.*; 13 14 21 public class UserAccountManagement extends ActionPanel { 22 23 24 private SharkAdmin workflowAdmin; 25 26 private TablePanel existingUsersPanel; 27 private ArrayList existingUsers=new ArrayList(); 28 29 public UserAccountManagement (SharkAdmin wa) { 30 super(); 31 this.workflowAdmin=wa; 32 super.init(); 33 } 34 35 protected void createActions () { 36 defaultActions=new Action[] { 37 new CreateUserAccount(this), 38 new RemoveUserAccount(this), 39 new ChangeUserAccountSettings(this), 40 new ChangeUserAccountPassword(this) 41 }; 42 } 43 44 protected Component createCenterComponent() { 45 Vector columnNames=new Vector(); 46 columnNames.add(ResourceManager.getLanguageDependentString("UsernameKey")); 47 columnNames.add(ResourceManager.getLanguageDependentString("FirstNameKey")); 48 columnNames.add(ResourceManager.getLanguageDependentString("LastNameKey")); 49 columnNames.add(ResourceManager.getLanguageDependentString("EmailAddressKey")); 50 51 existingUsersPanel=new TablePanel(columnNames, true); 52 return existingUsersPanel; 53 } 54 55 public SharkAdmin getWorkflowAdmin () { 56 return workflowAdmin; 57 } 58 59 public TablePanel getExistingUsersPanel () { 60 return existingUsersPanel; 61 } 62 63 public ArrayList getExistingUsers () { 64 return new ArrayList(existingUsers); 65 } 66 67 80 81 public void clear () { 82 existingUsers.clear(); 83 existingUsersPanel.removeAll(); 84 } 85 86 public synchronized void refresh (boolean mandatoryRefreshing) { 87 if (!(mandatoryRefreshing || isShowing())) return; 88 UserGroupAdministration uga=SharkAdmin.getUserGroupAmin(); 89 90 ArrayList oldEU=new ArrayList(existingUsers); 91 try { 92 94 existingUsers=new ArrayList(Arrays.asList(uga.getAllUsers())); 95 } catch (Throwable ex) { 96 System.out.println("Something went wrong during retrival of resources from engine"); 97 } 98 99 ArrayList toAdd=new ArrayList(existingUsers); 100 toAdd.removeAll(oldEU); 101 ArrayList toRemove=new ArrayList(oldEU); 102 toRemove.removeAll(existingUsers); 103 104 Iterator it=toRemove.iterator(); 106 while (it.hasNext()) { 107 try { 108 String username=(String )it.next(); 109 existingUsersPanel.removeElement(new Object []{username}); 110 } catch (Exception ex) { 111 System.out.println("Something went wrong during retrival of resource property"); 112 } 113 } 114 115 for (int i=0; i<existingUsersPanel.getTable().getRowCount(); i++) { 116 String uname=(String )existingUsersPanel.getTable().getValueAt(i,0); 117 try { 118 existingUsersPanel.setColumnValueOfSelectedRow(1,uga.getUserFirstName(uname)); 119 existingUsersPanel.setColumnValueOfSelectedRow(1,uga.getUserLastName(uname)); 120 existingUsersPanel.setColumnValueOfSelectedRow(2,uga.getUserEMailAddress(uname)); 121 }catch (Exception ex) {} 122 } 123 it=toAdd.iterator(); 125 while (it.hasNext()) { 126 String username=(String )it.next(); 127 Vector v=new Vector(); 128 try { 129 v.add(username); 130 v.add(uga.getUserFirstName(username)); 131 v.add(uga.getUserLastName(username)); 132 v.add(uga.getUserEMailAddress(username)); 133 existingUsersPanel.addElement(v); 134 } catch (Exception ex) { 135 System.out.println("Something went wrong during retrival of resource properties"); 136 ex.printStackTrace(); 137 } 138 } 139 } 140 141 } 142 | Popular Tags |