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

📄 bsconfwindow.java

📁 一款即时通讯软件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
package edu.ou.kmi.buddyspace.plugins.conference.gui;

/*
 * BSConfWindow.java
 *
 * Project: BuddySpace
 * (C) Copyright Knowledge Media Institute 2002
 *
 *
 * Created on 30 October 2002, 14:49
 */

import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import org.jabber.jabberbeans.util.*;

import edu.ou.kmi.buddyspace.core.*;
import edu.ou.kmi.buddyspace.gui.*;
import edu.ou.kmi.buddyspace.utils.*;
import edu.ou.kmi.buddyspace.plugins.conference.*;
import edu.ou.kmi.buddyspace.plugins.conference.core.*;
import edu.ou.kmi.buddyspace.plugins.simlink.gui.*;
import edu.ou.kmi.simlink.system.*;

/**
 * <code>BSConfWindow</code> is the conference chatroom GUI.
 *
 * @author  Jiri Komzak, Knowledge Media Institute, Open University, United Kingdom
 */
public class BSConfWindow extends AlertsDockableWindow
                          implements ActionListener, ItemListener,
                                     KeyListener, ParameterChangeListener,
                                     BSConfListener,
                                     BSVideoConferenceListener {

    private BSConfBeanInterface confBean = null;
    private BSVideoConferenceBean videoBean = null;

    private JID roomJID = null;
    private String myNick = null;
    private JID myJID = null;

    public static final String VOTE_YES_STR = "Voting YES";
    public static final String VOTE_NO_STR = "Voting NO";
    public static final String NOT_VOTING_STR = "Not voting";

    private PluginSimView pluginSimView;

    /*public static final String[] attentions = {"None", "Some", "Half", "Most",
                                               "Full"};*/
    public static final String[] presenceStrs = {"Wanna talk",
                                                 "Total attention",
                                                 "Normal attention",
                                                 "Low attention / Busy",
                                                 "Mind/body elsewhere",
                                                 "Away - be right back",
                                                 "Away for a while",
                                                 "Do not disturb"};
    //protected boolean dontSendAttention = false;

    protected Vector countdowns = null;

    private JPanel mainPanel;

    JScrollPane confScrollPane;
    BSAutoScrollTextPane confTextPane;
    JScrollPane rosterScrollPane;
    //JTextArea rosterTextArea;
    JScrollPane writeScrollPane;
    JTextArea writeTextArea;
    JPanel buttonPanel;
    JButton sendButton;
    JButton inviteButton;
    //JButton urlButton;
    JButton countdownButton;
    JButton videoButton;
    JButton closeButton;
    JComboBox showComboBox;
    JComboBox voteComboBox;
    //JSlider attentionSlider;
    private JButton dockButton;
    JButton bookmarkButton;
    private JCheckBox enterSendsCheckBox;
    private JCheckBox presenceChangesCheckBox;
    private JCheckBox alertsCheckBox;
    private JCheckBox pluginCheckBox;
    private JPanel checkBoxesPanel;
    private JButton historyButton;
    JPanel topLeftPanel;
    JPanel combosPanel;
    JPanel rosterPresPanel;
    JPanel bottomPanel;
    JPanel pluginPanel;
    JSplitPane topSplitPane;
    JSplitPane mainSplitPane;
    JSplitPane roomSplitPane;

    BSConfRosterTree rosterTree;

    private boolean enterSends = true;
    private boolean presenceChanges = false;
    private boolean alerts = true;

    /** Constructor */
    BSConfWindow(Window parent, BSConfWinManager winMan, String title,
                 Image icon, String roomName, String server, String nick,
                 BSConfBeanInterface confBean, boolean docked) {

        super(roomName+"@"+server, title, icon, new Dimension(400, 400), docked, winMan);

        this.confBean = confBean;
        if (confBean != null)
            confBean.addConfListener(this);

        roomJID = new JID(roomName, server, null);
        myJID = new JID(BSMainFrame.username, BSMainFrame.server, BSMainFrame.resource);
        myNick = nick;

        countdowns = new Vector();

        initComponents();

        videoBean = winMan.mainFrame.getCore().getVideoConferenceBean();
        if (videoBean != null)
        {
            videoBean.addVideoConferenceListener(this);
            videoBean.requestAuthorization(this);
        }

        if (confBean != null && roomJID != null)
            if (!confBean.createRoom(roomJID.getUsername(), roomJID.getServer(), myNick))
                close();

        sendPresence();

    }

    /** Inits GUI components */
    private void initComponents() {
        GridBagConstraints gridBagConstraints;

        mainPanel = new JPanel(new BorderLayout());

        //topLeftPanel = new JPanel(new BorderLayout());

        //*** conference chat text area ***
        confTextPane = new BSAutoScrollTextPane(true);
        confScrollPane = new JScrollPane();
        confScrollPane.setBorder(new javax.swing.border.TitledBorder("Room"));
        confScrollPane.setViewportView(confTextPane);

        if (((BSConfWinManager)winMan).mainFrame.pluginSimLink)
        {
            pluginPanel = new JPanel();
            pluginPanel.setLayout(new BorderLayout());
            pluginSimView = new PluginSimView(this, roomJID, this.myJID);
            pluginSimView.requestMenu(confBean.getMessengerBean());
            pluginPanel.add(pluginSimView);

            pluginPanel.setBorder(new javax.swing.border.TitledBorder("SimLink Plugin"));
            roomSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, pluginPanel,
                                           confScrollPane);
            roomSplitPane.setDividerSize(8);
            roomSplitPane.setResizeWeight(1);
            roomSplitPane.setDividerLocation(0);
        }

        //topLeftPanel.add(confScrollPane, BorderLayout.CENTER);

        //*** roster ***
        rosterTree = new BSConfRosterTree(confBean, roomJID, (BSConfWinManager)winMan);

        //*** presence ***
        ImageIcon[] presences = new ImageIcon[presenceStrs.length];
        presences[0] = new ImageIcon(ClassLoader.getSystemResource("images/hand.gif"));
        presences[0].setDescription(presenceStrs[0]);
        presences[1] = new ImageIcon(ClassLoader.getSystemResource("images/green_light.gif"));
        presences[1].setDescription(presenceStrs[2]);
        presences[2] = new ImageIcon(ClassLoader.getSystemResource("images/chat_light.gif"));
        presences[2].setDescription(presenceStrs[1]);
        presences[3] = new ImageIcon(ClassLoader.getSystemResource("images/busy.gif"));
        presences[3].setDescription(presenceStrs[3]);
        presences[4] = new ImageIcon(ClassLoader.getSystemResource("images/swoosh.gif"));
        presences[4].setDescription(presenceStrs[4]);
        presences[5] = new ImageIcon(ClassLoader.getSystemResource("images/yellow_light.gif"));
        presences[5].setDescription(presenceStrs[5]);
        presences[6] = new ImageIcon(ClassLoader.getSystemResource("images/xa_light.gif"));
        presences[6].setDescription(presenceStrs[6]);
        presences[7] = new ImageIcon(ClassLoader.getSystemResource("images/dnd_light.gif"));
        presences[7].setDescription(presenceStrs[7]);

        showComboBox = new JComboBox(presences);
        ImgIconListCellRenderer renderer = new ImgIconListCellRenderer();
        showComboBox.setRenderer(renderer);
        //showComboBox.setBorder(new javax.swing.border.TitledBorder("Attention"));
        showComboBox.setSelectedItem(presences[1]);
        showComboBox.addItemListener(this);

        //*** voting ***
        voteComboBox = new JComboBox();
        //voteComboBox.setBorder(new javax.swing.border.TitledBorder("Vote"));
        voteComboBox.addItem(NOT_VOTING_STR);
        voteComboBox.addItem(VOTE_YES_STR);
        voteComboBox.addItem(VOTE_NO_STR);
        voteComboBox.setSelectedItem(NOT_VOTING_STR);
        voteComboBox.addItemListener(this);

        combosPanel = new JPanel(new GridBagLayout());
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 2;
        combosPanel.add(showComboBox, gridBagConstraints);
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.insets = new Insets(0, 5, 0, 0);
        combosPanel.add(voteComboBox, gridBagConstraints);

        // countdown button
        countdownButton = new JButton("Countdown");
        Insets ins = countdownButton.getMargin();
        ins.left = ins.right = 3;
        countdownButton.setMargin(ins);
        countdownButton.addActionListener(this);
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 2;
        combosPanel.add(countdownButton, gridBagConstraints);

        presenceChangesCheckBox = new JCheckBox("Announce presence changes", presenceChanges);
        presenceChangesCheckBox.addActionListener(this);
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.anchor = GridBagConstraints.WEST;
        gridBagConstraints.insets = new Insets(0, 5, 0, 5);
        combosPanel.add(presenceChangesCheckBox, gridBagConstraints);

        alertsCheckBox = new JCheckBox("Chat-style alerts", alerts);
        alertsCheckBox.addActionListener(this);
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = GridBagConstraints.WEST;
        gridBagConstraints.insets = new Insets(0, 5, 0, 5);
        combosPanel.add(alertsCheckBox, gridBagConstraints);

        if (pluginSimView != null)
        {
            pluginCheckBox = new JCheckBox("Show plugin", false);
            pluginCheckBox.addActionListener(this);
            gridBagConstraints = new GridBagConstraints();
            gridBagConstraints.gridx = 1;
            gridBagConstraints.gridy = 5;
            gridBagConstraints.anchor = GridBagConstraints.WEST;
            gridBagConstraints.insets = new Insets(0, 5, 0, 5);
            combosPanel.add(pluginCheckBox, gridBagConstraints);
        }

        Icon videoIcon = new ImageIcon(ClassLoader.getSystemResource("images/flashmeeting-grey.gif"));
        videoButton = new JButton(videoIcon);
        videoButton.setToolTipText("Start FlashMeeting");
        ins = videoButton.getMargin();
        ins.left = ins.right = 0;
        ins.top = ins.bottom = 0;
        videoButton.setMargin(ins);
        videoButton.addActionListener(this);
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 4;
        combosPanel.add(videoButton, gridBagConstraints);

        // *** attention slider ***
        /*int attentionLabelMajorStep = attentions.length-1;
        attentionSlider = new JSlider(JSlider.HORIZONTAL, 0,
                                      attentions.length-1, attentions.length-1);
        attentionSlider.addChangeListener(this);
        Hashtable labels = new Hashtable();
        for (int i=0; i<attentions.length; i += attentionLabelMajorStep) {
            JLabel l = new JLabel(attentions[i]);
            Font f = l.getFont();
            l.setFont(new Font(f.getFontName(), f.getStyle(), f.getSize()-3));
            labels.put(new Integer(i), l);
        }
        attentionSlider.setLabelTable(labels);
        attentionSlider.setMajorTickSpacing(attentionLabelMajorStep);
        attentionSlider.setMinorTickSpacing(1);
        attentionSlider.setSnapToTicks(true);
        attentionSlider.setPaintTicks(true);
        attentionSlider.setPaintLabels(true);
        attentionSlider.setBorder(BorderFactory.createTitledBorder("Attention"));
        attentionSlider.doLayout();
        //topLeftPanel.add(attentionSlider, BorderLayout.SOUTH);
        gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints.gridy = 4;
        combosPanel.add(attentionSlider, gridBagConstraints);*/

        //*** roster presence panel ***
        rosterPresPanel = new JPanel(new BorderLayout());
        //rosterPresPanel.add(rosterScrollPane, BorderLayout.CENTER);
        rosterPresPanel.add(rosterTree.getScrollPane(), BorderLayout.CENTER);
        rosterPresPanel.add(combosPanel, BorderLayout.SOUTH);

        Component leftPane = confScrollPane;
        if (roomSplitPane != null) leftPane = roomSplitPane;
        topSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, leftPane, rosterPresPanel);
        //topSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, confScrollPane, rosterPresPanel);
        //topSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, topLeftPanel, rosterPresPanel);
        topSplitPane.setBorder(null);
        topSplitPane.setDividerSize(8);

⌨️ 快捷键说明

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