1 package org.ozoneDB.adminGui.feature.account.groups; 8 9 import java.awt.BorderLayout ; 10 import java.util.Vector ; 11 import javax.swing.JDialog ; 12 13 import org.ozoneDB.adminGui.widget.AssignmentPanel; 14 import org.ozoneDB.adminGui.widget.ButtonPanel; 15 import org.ozoneDB.adminGui.widget.ButtonPanelListener; 16 import org.ozoneDB.adminGui.main.AdminGui; 17 18 19 28 30 public class WorkGroupDialog extends JDialog implements ButtonPanelListener { 31 32 33 private String group = null; 34 35 private Vector userNames = null; 36 37 private Vector assignedUserNames = null; 38 39 private WorkGroupPanel groupPane = null; 40 41 private AssignmentPanel assignPane = null; 42 43 private String [] button = {"OK", "Cancel"}; 44 45 private boolean ok = false; 46 47 48 53 public WorkGroupDialog(Vector userNames) { 54 super(AdminGui.instance(), "Create Group", true); 55 this.userNames = userNames; 56 57 try { 58 init(); 59 this.setSize(390, 290); 60 } catch (Exception e) { 61 e.printStackTrace(); 62 } 63 } 64 65 73 public WorkGroupDialog(String group, Vector userNames, 74 Vector assignedUserNames) { 75 super(AdminGui.instance(), "Create Group", true); 76 this.group = group; 77 this.userNames = userNames; 78 this.assignedUserNames = assignedUserNames; 79 80 try { 81 init(); 82 this.setSize(390, 290); 83 } catch (Exception e) { 84 e.printStackTrace(); 85 } 86 } 87 88 91 private void init() throws Exception { 92 this.setResizable(false); 94 this.setLocationRelativeTo(AdminGui.instance()); 95 this.getContentPane().setLayout(new BorderLayout ()); 96 97 groupPane = new WorkGroupPanel(group); 99 assignPane = new AssignmentPanel("Users", userNames, assignedUserNames); 100 101 ButtonPanel buttonPane = new ButtonPanel(this.button); 102 buttonPane.addConnectionListener(this); 103 104 this.getContentPane().add(groupPane, BorderLayout.NORTH); 106 this.getContentPane().add(assignPane, BorderLayout.CENTER); 107 this.getContentPane().add(buttonPane, BorderLayout.SOUTH); 108 } 109 110 115 public void buttonExecute(String buttonName) { 116 if (button[0].equals(buttonName)) 118 collectGroupInfo(); 119 120 else 122 this.hide(); 123 } 124 125 128 private void collectGroupInfo() { 129 this.assignedUserNames = this.assignPane.getAssignedValues(); 130 String name = this.groupPane.getGroup().trim(); 131 132 if (name.equals("") | name == null) 134 this.ok = false; 135 else 136 this.ok = true; 137 138 this.hide(); 139 } 140 141 146 public String getName() { 147 return this.groupPane.getGroup(); 148 } 149 150 156 public boolean isOK() { 157 return this.ok; 158 } 159 160 165 public Vector getUsers() { 166 return this.assignedUserNames; 167 } 168 169 } | Popular Tags |