1 package org.enhydra.shark.swingclient.workflowadmin.user; 2 3 import java.awt.*; 4 import java.util.*; 5 6 import javax.swing.*; 7 8 9 import org.enhydra.shark.api.client.wfservice.*; 10 import org.enhydra.shark.swingclient.*; 11 import org.enhydra.shark.swingclient.workflowadmin.*; 12 import org.enhydra.shark.swingclient.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++) { 117 String uname=(String )existingUsersPanel.getTable().getValueAt(i,0); 118 try { 119 existingUsersPanel.setColumnValueOfSelectedRow(1,uga.getUserFirstName(uname)); 120 existingUsersPanel.setColumnValueOfSelectedRow(2,uga.getUserLastName(uname)); 121 existingUsersPanel.setColumnValueOfSelectedRow(3,uga.getUserEMailAddress(uname)); 122 }catch (Exception ex) {} 123 } 124 125 it=toAdd.iterator(); 127 while (it.hasNext()) { 128 String username=(String )it.next(); 129 Vector v=new Vector(); 130 try { 131 v.add(username); 132 v.add(uga.getUserFirstName(username)); 133 v.add(uga.getUserLastName(username)); 134 v.add(uga.getUserEMailAddress(username)); 135 existingUsersPanel.addElement(v); 136 } catch (Exception ex) { 137 System.out.println("Something went wrong during retrival of resource properties"); 138 ex.printStackTrace(); 139 } 140 } 141 142 } 143 144 } 145 | Popular Tags |