From 621d9e5c413e561293d7484b93882d985b3fe15f Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Sat, 24 Mar 2012 02:27:47 -0500 Subject: Removed unnecessary pki folder. Previously the source code was located inside a pki folder. This folder was created during svn migration and is no longer needed. This folder has now been removed and the contents have been moved up one level. Ticket #131 --- .../com/netscape/admin/certsrv/ug/GroupEditor.java | 596 +++++++++++++++++++++ 1 file changed, 596 insertions(+) create mode 100644 base/console/src/com/netscape/admin/certsrv/ug/GroupEditor.java (limited to 'base/console/src/com/netscape/admin/certsrv/ug/GroupEditor.java') diff --git a/base/console/src/com/netscape/admin/certsrv/ug/GroupEditor.java b/base/console/src/com/netscape/admin/certsrv/ug/GroupEditor.java new file mode 100644 index 000000000..e9693b15d --- /dev/null +++ b/base/console/src/com/netscape/admin/certsrv/ug/GroupEditor.java @@ -0,0 +1,596 @@ +// --- BEGIN COPYRIGHT BLOCK --- +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; version 2 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// (C) 2007 Red Hat, Inc. +// All rights reserved. +// --- END COPYRIGHT BLOCK --- +package com.netscape.admin.certsrv.ug; + +import com.netscape.admin.certsrv.*; +import com.netscape.admin.certsrv.connection.*; +import javax.swing.*; +import javax.swing.event.*; +import java.awt.event.*; +import java.awt.*; +import java.util.*; + +import com.netscape.management.client.util.*; +import com.netscape.certsrv.common.*; + +/** + * Group Membership Editor + * + * @author Jack Pan-Chen + * @version $Revision$, $Date$ + * @see com.netscape.admin.certsrv.ug + */ +public class GroupEditor extends JDialog + implements ActionListener, ListSelectionListener +{ + + /*========================================================== + * variables + *==========================================================*/ + private String PREFIX = "GROUPEDITOR"; + + private JFrame mParentFrame; + private AdminConnection mConnection; + private String mGroupName; + private boolean mIsNewGroup = false; + private ResourceBundle mResource; + protected DefaultListModel mDataModel; + protected UserListDialog mUserDialog = null; //keeping a copy for reuse + + protected JScrollPane mScrollPane; + protected JList mList; + + private JButton mOK, mCancel, mHelp, mAddUser, mDelete; + private JTextField mGroupNameField, mGroupDescField; + private JLabel mGroupNameLabel; + + private static final String ADDHELPINDEX = + "usersgroups-certsrv-add-group-dbox-help"; + private static final String EDITHELPINDEX = + "usersgroups-certsrv-edit-group-dbox-help"; + private String mHelpToken; + + /*========================================================== + * constructors + *==========================================================*/ + public GroupEditor(JFrame parent, AdminConnection conn) { + super(parent,true); + mParentFrame = parent; + mConnection = conn; + mDataModel = new DefaultListModel(); + mResource = ResourceBundle.getBundle(CMSAdminResources.class.getName()); + + setSize(360, 300); + setTitle(mResource.getString(PREFIX+"_TITLE")); + setLocationRelativeTo(parent); + getRootPane().setDoubleBuffered(true); + setDisplay(); + //toFront(); + } + + /*========================================================== + * public methods + *==========================================================*/ + + /** + * show the windows + * @param users list of current groups + */ + public void showDialog(String group, boolean isNew) { + + //initialize and setup + mGroupName = group; + mIsNewGroup = isNew; + + if (isNew) + mHelpToken = ADDHELPINDEX; + else + mHelpToken = EDITHELPINDEX; + + mGroupDescField.setText(""); + mGroupNameField.setText(""); + + mDataModel.clear(); + + //disable name change + if(!mIsNewGroup) { + mGroupNameField.setVisible(false); + mGroupNameLabel.setVisible(true); + mGroupNameLabel.setText(mGroupName); + } else { + mGroupNameField.setVisible(true); + mGroupNameLabel.setVisible(false); + } + + //retrieve the user record from the server + try { + if (mIsNewGroup == false) + refresh(); + } catch (EAdminException ex) { + CMSAdminUtil.showErrorDialog(mParentFrame, mResource, + ex.toString(), CMSAdminUtil.ERROR_MESSAGE); + return; + } + + setButtons(); + this.show(); + } + + /*========================================================== + * EVNET HANDLER METHODS + *==========================================================*/ + + //=== ACTIONLISTENER ===================== + + public void actionPerformed(ActionEvent evt) { + + if (evt.getSource().equals(mOK)) { + + if (mIsNewGroup) { + + //check text fields + if (mGroupNameField.getText().trim().equals("")) { + CMSAdminUtil.showMessageDialog(mParentFrame, mResource, PREFIX, + "NOGROUPNAME", CMSAdminUtil.ERROR_MESSAGE); + return; + } + + try { + mGroupName = mGroupNameField.getText().trim(); + addGroup(); + } catch (EAdminException e) { + //display error dialog + Debug.println(e.toString()); + CMSAdminUtil.showErrorDialog(mParentFrame, mResource, + e.toString(), CMSAdminUtil.ERROR_MESSAGE); + return; + } + + } else { + + try { + modifyGroup(); + } catch (EAdminException e) { + //display error dialog + Debug.println(e.toString()); + CMSAdminUtil.showErrorDialog(mParentFrame, mResource, + e.toString(), CMSAdminUtil.ERROR_MESSAGE); + return; + } + + } + this.hide(); + } + + if (evt.getSource().equals(mCancel)) { + Debug.println("Cancel Pressed"); + + //display are you sure dialog + this.hide(); + } + + if (evt.getSource().equals(mHelp)) { + CMSAdminUtil.help(mHelpToken); + } + + if (evt.getSource().equals(mAddUser)) { + //bring up the list for selection + + //create vector here + Vector currentUser = new Vector(); + for (int i=0; i0) + for (int i=0; i0) + userBuf.append(","); + userBuf.append(data); + } + + //set parameters + config.put(Constants.PR_GROUP_USER, userBuf.toString()); + } + + //refresh the table content + private void refreshTable() { + //Debug.println("GroupEditor: refreshTable() - start"); + //mTable.invalidate(); + //mTable.validate(); + //mTable.repaint(1); + //mScrollPane.invalidate(); + //mScrollPane.validate(); + //mScrollPane.repaint(1); + //Debug.println("GroupEditor: refreshTable() - end"); + } + + public JList makeJList(DefaultListModel listModel, int visibleCount) { + JList listbox = new JList(listModel); + listbox.setCellRenderer(new AttrCellRenderer()); + listbox.setSelectionModel(new DefaultListSelectionModel()); + listbox.setVisibleRowCount(visibleCount); + if(listModel.size()!=0) + listbox.setSelectedIndex(0); + return listbox; + } + +} + + -- cgit