📄 groupmanagerdialog.java
字号:
/*ARMiner - Association Rules MinerCopyright (C) 2000 UMass/Boston - Computer Science DepartmentThis program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or (atyour option) any later version.This program is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USAThe ARMiner Server was written by Dana Cristofor and LaurentiuCristofor.The ARMiner Client was written by Abdelmajid Karatihy, Xiaoyong Kuang,and Lung-Tsung Li.The ARMiner package is currently maintained by Laurentiu Cristofor(laur@cs.umb.edu).*//* This file is a part of the ARMiner project. (P)1999-2000 by ARMiner Client Team: Abdelmajid Karatihy Xiaoyong Kuang Lung-Tsung Li*/import java.util.*;import javax.swing.*;import javax.swing.event.*;import java.awt.event.*;import java.awt.*;/* Maintenance log started on November 20th, 2000 by Laurentiu Cristofor Nov. 20th, 2000 - made some style changes Nov. 21st, 2000 - resized and repositioned widgets*/ /** * GroupManagerDialog.java<P> * * Create a dialog to allow the user to be able to add a new group, change an * existing group's name and its associated users. * */public class GroupManagerDialog extends CenteredDialog { /** Initializes the Form */ public GroupManagerDialog(javax.swing.JFrame parent, boolean modal, Vector groups, Vector users) { super (parent, "Group Management", modal); setSize(500,340); this.parent = parent; this.groups = groups; groups.insertElementAt("New Group",0); groupusers.add(Client.userName); this.users = users; setNonGroupUsers(); initComponents (); setLocation(getDialogCenteredLoc(parent)); setResizable(false); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the FormEditor. */ private void initComponents () {//GEN-BEGIN:initComponents //setBackground (new java.awt.Color (204, 204, 204)); addWindowListener (new java.awt.event.WindowAdapter () { public void windowClosing (java.awt.event.WindowEvent evt) { closeDialog (evt); } }); getContentPane ().setLayout (new com.netbeans.developer.awt.AbsoluteLayout ()); jbtnClose = new javax.swing.JButton ("Close"); jbtnClose.setMnemonic(KeyEvent.VK_C); jbtnClose.addActionListener (new java.awt.event.ActionListener () { public void actionPerformed (java.awt.event.ActionEvent evt) { jbtnCloseActionPerformed (); } }); jbtnClose.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == KeyEvent.VK_ENTER){ jbtnCloseActionPerformed(); } } }); jbtnClose.requestFocus(); getContentPane ().add (jbtnClose, new com.netbeans.developer.awt.AbsoluteConstraints (400, 30, 75, 25)); getContentPane ().add (new javax.swing.JLabel("Group List:"), new com.netbeans.developer.awt.AbsoluteConstraints (20, 10, 90, 20)); jcbGroupList = new javax.swing.JComboBox (groups); jcbGroupList.setMaximumRowCount(6); jcbGroupList.addActionListener (new java.awt.event.ActionListener () { public void actionPerformed (java.awt.event.ActionEvent evt) { jcbGroupListActionPerformed (evt); } }); getContentPane().add (jcbGroupList, new com.netbeans.developer.awt.AbsoluteConstraints (20, 30, 130, 25)); jbtnAdd = new javax.swing.JButton ("Add"); jbtnAdd.setMnemonic(KeyEvent.VK_A); jbtnAdd.addActionListener (new java.awt.event.ActionListener () { public void actionPerformed (java.awt.event.ActionEvent evt) { jbtnAddActionPerformed (evt); } }); getContentPane ().add (jbtnAdd, new com.netbeans.developer.awt.AbsoluteConstraints (160, 30, 75, 25)); jbtnDelete = new javax.swing.JButton ("Delete"); jbtnDelete.setMnemonic(KeyEvent.VK_D); jbtnDelete.addActionListener (new java.awt.event.ActionListener () { public void actionPerformed (java.awt.event.ActionEvent evt) { jbtnDeleteActionPerformed (evt); } }); getContentPane ().add (jbtnDelete, new com.netbeans.developer.awt.AbsoluteConstraints (240, 30, 75, 25)); jbtnSave = new javax.swing.JButton ("Save"); jbtnSave.setMnemonic(KeyEvent.VK_S); jbtnSave.addActionListener (new java.awt.event.ActionListener () { public void actionPerformed (java.awt.event.ActionEvent evt) { jbtnSaveActionPerformed (evt); } }); getContentPane ().add (jbtnSave, new com.netbeans.developer.awt.AbsoluteConstraints (320, 30, 75, 25)); jbtnSave.setEnabled(false); getContentPane().add (new javax.swing.JLabel("Group Name:"), new com.netbeans.developer.awt.AbsoluteConstraints (20, 70, 100, 20)); jtxfGroupName = new javax.swing.JTextField (); getContentPane ().add (jtxfGroupName, new com.netbeans.developer.awt.AbsoluteConstraints (20, 90, 130, 25)); getContentPane ().add (new javax.swing.JLabel("Group Owner: "), new com.netbeans.developer.awt.AbsoluteConstraints (170, 90, 120, 30)); jlbOwner = new javax.swing.JLabel (); getContentPane ().add (jlbOwner, new com.netbeans.developer.awt.AbsoluteConstraints (260, 90, 120, 30)); jbtnRefresh = new javax.swing.JButton("Refresh"); jbtnRefresh.setMnemonic(KeyEvent.VK_R); jbtnRefresh.addActionListener (new java.awt.event.ActionListener () { public void actionPerformed (java.awt.event.ActionEvent evt) { jbtnRefreshActionPerformed (evt); } }); getContentPane ().add (jbtnRefresh, new com.netbeans.developer.awt.AbsoluteConstraints (380, 90, 95, 25)); getContentPane ().add (new javax.swing.JLabel("Users Not In Group:"), new com.netbeans.developer.awt.AbsoluteConstraints (20, 140, 140, 20)); jlstUserList = new javax.swing.JList (nonGroupusers); jlstUserList.setBorder (new javax.swing.border.EtchedBorder ()); scrollPane1 = new JScrollPane(jlstUserList); scrollPane1.setAlignmentX(LEFT_ALIGNMENT); scrollPane1.setAlignmentY(TOP_ALIGNMENT); getContentPane().add (scrollPane1, new com.netbeans.developer.awt.AbsoluteConstraints (20, 160, 170, 130)); jbtnForward = new javax.swing.JButton (last); jbtnForward.addActionListener (new java.awt.event.ActionListener () { public void actionPerformed (java.awt.event.ActionEvent evt) { jbtnForwardActionPerformed (evt); } }); getContentPane ().add (jbtnForward, new com.netbeans.developer.awt.AbsoluteConstraints (220, 180, 43, 30)); jbtnBackward = new javax.swing.JButton (first); jbtnBackward.addActionListener (new java.awt.event.ActionListener () { public void actionPerformed (java.awt.event.ActionEvent evt) { jbtnBackwardActionPerformed (evt); } }); getContentPane ().add (jbtnBackward, new com.netbeans.developer.awt.AbsoluteConstraints (220, 230, 43, 30)); getContentPane ().add (new javax.swing.JLabel("Users In Group:"), new com.netbeans.developer.awt.AbsoluteConstraints (310, 140, 120, 20)); jlstGroupUser = new javax.swing.JList(groupusers); jlstGroupUser.setBorder (new javax.swing.border.EtchedBorder ()); scrollPane2 = new JScrollPane(jlstGroupUser); scrollPane2.setAlignmentX(LEFT_ALIGNMENT); scrollPane2.setAlignmentY(TOP_ALIGNMENT); getContentPane ().add (scrollPane2, new com.netbeans.developer.awt.AbsoluteConstraints (310, 160, 160, 130)); }//GEN-END:initComponents private void jbtnSaveActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnSaveActionPerformed // Add your handling code here: Vector info = new Vector(); boolean isChanged = false; String grp = jtxfGroupName.getText().trim(); if (!grp.equals(groupInfo.groupName)) { info.add(groupInfo.groupName); info.add(grp); try { Client.modifyGroupName(info); JOptionPane.showMessageDialog(this, "The group " + groupInfo.groupName + " has been succesfully changed to " + grp); isChanged = true; refresh(); selectedGrp = grp; //System.out.println("selected Group: " + selectedGrp); jcbGroupList.setSelectedItem(selectedGrp); } catch(ClientErrorException e) { JOptionPane.showMessageDialog(this, "GroupManagerDialog: Client Error in modifying group's name:\n " + e.toString() + "\nTransaction aborted!"); return; } } info.clear(); if (!groupInfo.groupUsers.equals(groupusers)) { info.add(grp); info.add(groupusers); try { Client.setUsersForGroup(info); JOptionPane.showMessageDialog(this, "The group's user(s) has been successfully modified."); isChanged = true; refresh(); resetGroupInfo(selectedGrp); } catch(ClientErrorException e) { JOptionPane.showMessageDialog(this, "GroupManagerDialog: Client Error in adding group users:\n " + e.toString() + "\nTransaction aborted!"); return; } catch(ClientWarningException e) { JOptionPane.showMessageDialog(this, "GroupManagerDialog: Client Warning in adding group users:\n " + e.toString()); //return; } } if (isChanged == false) JOptionPane.showMessageDialog(this, "User information doesn't get changed, no transaction performed!"); repaint(); }//GEN-LAST:event_jbtnSaveActionPerformed private void jbtnDeleteActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnDeleteActionPerformed // Add your handling code here: int index = jcbGroupList.getSelectedIndex(); if (index <= 0) { JOptionPane.showMessageDialog(this, "Must select a group to delete."); return; } String grp = (String)jcbGroupList.getSelectedItem(); int result; result = JOptionPane.showConfirmDialog(this, "You are about to delete the group " + grp + ".\n Are you sure you want to do that?" ); if (result == JOptionPane.NO_OPTION) return; else if (result == JOptionPane.YES_OPTION) { Vector request = new Vector(); request.add(jcbGroupList.getSelectedItem()); try { Client.deleteGroup(request); JOptionPane.showMessageDialog(this, "The group: " + grp + " has been successfully deleted."); } catch(ClientErrorException e) { JOptionPane.showMessageDialog(this, "GroupManager: Client Error in deleting a group from DBConfig:\n " + e.toString() + "\nTransaction aborted!"); return; } jcbGroupList.setSelectedIndex(0); groups.remove(grp); repaint(); reinitialize(); } }//GEN-LAST:event_jbtnDeleteActionPerformed private void jbtnRefreshActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnRefreshActionPerformed // Add your handling code here: refresh(); //System.out.println("selected Group in Refresh: " + selectedGrp); if ((!groups.contains(selectedGrp)) && (selectedGrp != null)) { JOptionPane.showMessageDialog(this, "GroupManager: the selected group " + selectedGrp + " is likely to have been removed by another user."); reinitialize(); jcbGroupList.setSelectedIndex(0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -