⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 workgroupdialog.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
字号:
//// You can redistribute this software and/or modify it under the terms of
// the Ozone Library License version 1 published by ozone-db.org.
//
// The original code and portions created by SMB are
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
//
package org.ozoneDB.adminGui.feature.account.groups;

import java.awt.BorderLayout;
import java.util.Vector;
import javax.swing.JDialog;

import org.ozoneDB.adminGui.widget.AssignmentPanel;
import org.ozoneDB.adminGui.widget.ButtonPanel;
import org.ozoneDB.adminGui.widget.ButtonPanelListener;
import org.ozoneDB.adminGui.main.AdminGui;


//#############################################################################
/**
 * This class gets a new group name to be created.
 *
 * @author  <p align=center>Ibsen Ramos-Bonilla
 * <br>Copyright &copy 1997-@year@ by SMB GmbH. All Rights Reserved.</p>
 *
 * @version 1.0
 */
//#############################################################################

public class WorkGroupDialog extends JDialog implements ButtonPanelListener {

    /** Group calling the work dialog. */
    private String group = null;
    /** A list of account names. */
    private Vector userNames = null;
    /** A list of assigned account names. */
    private Vector assignedUserNames = null;
    /** Panel used to get the group name. */
    private WorkGroupPanel groupPane = null;
    /** Panel used to assign users at time of group creation. */
    private AssignmentPanel assignPane = null;
    /** List of buttons for the button panel. */
    private String[] button = {"OK", "Cancel"};
    /** Flag to monitor if the ok buttons was clicked. */
    private boolean ok = false;


    /**
     * Overloaded constructor creates the work group dialog from a new group.
     *
     * @param userNames - the list of names available for use.
     */
    public WorkGroupDialog(Vector userNames) {
        super(AdminGui.instance(), "Create Group", true);
        this.userNames = userNames;

        try {
            init();
            this.setSize(390, 290);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * Overloaded constructor creates the work group dialog from an existing
     * group.
     *
     * @param group - the group name.
     * @param userNames - the list of names available for use.
     * @param assignedUserNames - the list of assigned users already in the group.
     */
    public WorkGroupDialog(String group, Vector userNames,
                           Vector assignedUserNames) {
        super(AdminGui.instance(), "Create Group", true);
        this.group = group;
        this.userNames = userNames;
        this.assignedUserNames = assignedUserNames;

        try {
            init();
            this.setSize(390, 290);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * This method initializes the dialog.
     */
    private void init() throws Exception {
        //set dialog attributes
        this.setResizable(false);
        this.setLocationRelativeTo(AdminGui.instance());
        this.getContentPane().setLayout(new BorderLayout());

        //create panels
        groupPane = new WorkGroupPanel(group);
        assignPane = new AssignmentPanel("Users", userNames, assignedUserNames);

        ButtonPanel buttonPane = new ButtonPanel(this.button);
        buttonPane.addConnectionListener(this);

        //add the dialog components
        this.getContentPane().add(groupPane, BorderLayout.NORTH);
        this.getContentPane().add(assignPane, BorderLayout.CENTER);
        this.getContentPane().add(buttonPane, BorderLayout.SOUTH);
    }

    /**
     * This method handles the button clicks..
     *
     * @param buttonName - name of the button pressed.
     */
    public void buttonExecute(String buttonName) {
        //ok
        if (button[0].equals(buttonName))
            collectGroupInfo();

        //cancel
        else
            this.hide();
    }

    /**
     * This method is called when the ok button is clicked.
     */
    private void collectGroupInfo() {
        this.assignedUserNames = this.assignPane.getAssignedValues();
        String name = this.groupPane.getGroup().trim();

        //verify that we have a valid entry
        if (name.equals("") | name == null)
            this.ok = false;
        else
            this.ok = true;

        this.hide();
    }

    /**
     * This method returns the group name.
     *
     * @return String - the new group name.
     */
    public String getName() {
        return this.groupPane.getGroup();
    }

    /**
     * This method denotes if the ok button was pushed.
     *
     * @return boolean - TRUE = OK button pushed.
     *                   FALSE = Cancel button pushed.
     */
    public boolean isOK() {
        return this.ok;
    }

    /**
     * This method returns a list of the names selected in the Users list.
     *
     * @return Vector - a list of assigned account names.
     */
    public Vector getUsers() {
        return this.assignedUserNames;
    }

} //--------------------------------- E O F -----------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -