private void updateDisplays() { if (sliceList.isSelectionEmpty()) return; Slice d = (Slice) sliceList.getSelectedValue(); if (d.urn.equals(textFieldSliceURN.getText())) // is an updated really necessary? return; textFieldSliceURN.setText(d.urn); textAreaDesc.setText(d.desc); textFieldExpiry.setText(Utils.utcTolocal(d.expiry)); textFieldCreation.setText(Utils.utcTolocal(d.creation)); textFieldProjectURN.setText(d.urnProject); tableModel.clear(); // if(d.members.size() == 0) LinkedList<Membership> members = SliceAuthorityAPI.lookupMembers(d.urn, "SLICE"); if (members == null) { showErrorMessage(); return; } d.members = members; for (int i = 0; i < members.size(); i++) { tableModel.add(members.get(i).urn, members.get(i).role); } }
private void showChangeRoleDialog() { Slice slice = (Slice) sliceList.getSelectedValue(); int row = memberTable.convertRowIndexToModel(memberTable.getSelectedRow()); String role = slice.members.get(row).role; String availableRoles[]; if (role.equals("MEMBER")) availableRoles = new String[] {"LEAD", "ADMIN"}; else if (role.equals("ADMIN")) availableRoles = new String[] {"LEAD", "MEMBER"}; else { JOptionPane.showMessageDialog( this, "There must always be a LEAD role for a slice.\nAssigning LEAD role to another member would automatically change this user's role to MEMBER.", "Alter Role", JOptionPane.INFORMATION_MESSAGE); return; } String newRole = (String) JOptionPane.showInputDialog( null, "Select new role member:", "Change Member Role", JOptionPane.PLAIN_MESSAGE, null, availableRoles, availableRoles[0]); if (newRole != null) { Membership rsp = SliceAuthorityAPI.changeMemberRole( slice.urn, slice.members.get(row).urn, newRole, slice.members.get(row).type); if (rsp != null) { // Let's perform a lookup again to get a fresh member list LinkedList<Membership> members = SliceAuthorityAPI.lookupMembers(slice.urn, slice.members.get(row).type); if (members == null) return; slice.members = members; tableModel.clear(); for (int i = 0; i < slice.members.size(); i++) tableModel.add(slice.members.get(i).urn, slice.members.get(i).role); } else showErrorMessage(); } }
private void showAddMemberDialog() { Slice slice = (Slice) sliceList.getSelectedValue(); HashSet<String> existingMembers = new HashSet<String>(); for (int i = 0; i < slice.members.size(); i++) existingMembers.add(slice.members.get(i).urn); HashSet<String> nonMembers = new HashSet<String>(); Object[] allMembers = mainGUI.getMembersArray(); for (int i = 0; i < allMembers.length; i++) { Member m = (Member) allMembers[i]; // Ignore Revoked members if (MemberAuthorityAPI.crl.getRevokedCertificate(m.cert) != null) continue; String urn = m.urn; if (!existingMembers.contains(urn)) nonMembers.add(urn); } String[] choiceArray = nonMembers.toArray(new String[0]); if (choiceArray.length == 0) { JOptionPane.showMessageDialog( Slices.this, "There are no more active members to add to this slice.", "Add Member", JOptionPane.INFORMATION_MESSAGE); } else { String newMember = (String) JOptionPane.showInputDialog( null, "Select new member for slice " + slice.name + "\n", "Add Member", JOptionPane.PLAIN_MESSAGE, null, choiceArray, choiceArray[0]); if (newMember != null) { Membership mem = SliceAuthorityAPI.addMember(slice.urn, newMember, "SLICE"); if (mem != null) { tableModel.add(newMember, "MEMBER"); slice.members.add(mem); } else showErrorMessage(); } } }