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

📄 buddylist.java~

📁 JBother是纯Java开发的Jabber(即时消息开源软件)客户端。支持群组聊天
💻 JAVA~
📖 第 1 页 / 共 3 页
字号:
    /**     *  Returns the current status string     *     *@return    the current status string     */    public String getCurrentStatusString()    {        return this.currentStatusString;    }    /**     *  Returns the group chat frame     *     *@return    the group chat frame     */    public TabFrame getTabFrame()    {        return tabFrame;    }    /**     *  Starts the group chat frame     */    public void startTabFrame()    {        if( tabFrame == null )        {            tabFrame = new TabFrame();        }    }    /**     *  checks to see if there are no more chat room windows in the     *  groupchatframe if there are no more, the groupchatframe is destroyed     */    public void stopTabFrame()    {        if( tabFrame == null )        {            return;        }        if( tabFrame.tabsLeft() <= 0 )        {            tabFrame.saveStates();            if( !docked )            {                tabFrame.removeTabListeners();                DialogTracker.removeDialog( tabFrame );                tabFrame = null;                com.valhalla.Logger.debug( "Removing chat frame" );            }        }    }    /**     *  Removes a ChatPanel     *     *@param  panel  the chat panel to remove     */    public void removeTabPanel( TabFramePanel panel )    {        if( tabFrame == null )        {            return;        }        tabFrame.removePanel( panel );        stopTabFrame();    }    /**     *  Adds a chat room window to the groupchat frame. If there is not     *  groupchat frame one is created     *     *@param  panel  The feature to be added to the TabPanel attribute     */    public void addTabPanel( TabFramePanel panel )    {        if( tabFrame == null )        {            tabFrame = new TabFrame();        }        tabFrame.addPanel( panel );        if( !tabFrame.isVisible() )        {            tabFrame.setVisible( true );            tabFrame.toFront();        }    }    /**     *  Gets the buddy status     *     *@param  userId  the user id of the BuddyStatus     *@return         The buddyStatus value     */    public BuddyStatus getBuddyStatus( String userId )    {        if( userId == null )        {            return null;        }        if( buddyStatuses == null )        {            buddyStatuses = new Hashtable();        }        BuddyStatus buddy = new BuddyStatus( userId );        if( buddyStatuses.get( userId.toLowerCase() ) != null )        {            buddy = (BuddyStatus)buddyStatuses.get( userId.toLowerCase() );        }        else        {            buddy.newPubKey();            buddyStatuses.put( userId.toLowerCase(), buddy );        }        return buddy;    }    /**     *  Returns all the buddy status that are available     *     *@return    the Hashtable containing all the buddy statuses     */    public Hashtable getBuddyStatuses()    {        return this.buddyStatuses;    }    /**     *  Returns the current connection     *     *@return    the current connection     */    public XMPPConnection getConnection()    {        return this.connection;    }    /**     *  Checks to see if a connection is active     *     *@return    true if the connection is active (connected)     */    public boolean checkConnection()    {        if( connection == null || !connection.isConnected() )        {            return false;        }        else        {            return true;        }    }    /**     *  Displays a generic connection error     */    public void connectionError()    {        Standard.warningMessage( null, resources.getString( "connectionError" ),                resources.getString( "notConnected" ) );    }    /**     *  Gets the docked attribute of the BuddyList object     *     *@return    The docked value     */    public boolean isDocked()    {        return docked;    }    /**     *  Description of the Method     */    public void dockYourself()    {        if( frame != null )        {            frame.remove( this );            frame.dispose();        }        if( tabFrame == null )        {            tabFrame = new TabFrame();        }        tabFrame.dockBuddyList( this );//        tabFrame.setJMenuBar(topMenu);        frame = tabFrame;        frame.setVisible( true );        docked = true;    }    /**     *  Sets the tabFrame attribute of the BuddyList object     *     *@param  frame  The new tabFrame value     */    public void setTabFrame( TabFrame frame )    {        this.tabFrame = frame;    }    /**     *  Description of the Method     */    public void undock()    {        docked = false;        if( tabFrame != null )        {            tabFrame.undock();            stopTabFrame();        }        if( tabFrame != null )        {            tabFrame.setVisible( true );        }        BuddyListContainerFrame f = new BuddyListContainerFrame( this );        frame = f;        frame.setVisible( true );    }    /**     *  Loads the settings for this profile     */    public void loadSettings()    {        ConnectorThread.getInstance().resetCredentials();        buddyStatuses = new Hashtable();        loadBlockedUsers();        loadNotDeliveredMessages();        gnupgPassword = null;        Vector panels = MessageDelegator.getInstance().getPanels();        int size = panels.size();        for( int i = 0; i < size; i++ )        {            ConversationPanel panel = (ConversationPanel)panels.get( 0 );            panel.closeHandler();        }        panels.removeAllElements();        if( tabFrame != null )        {            tabFrame.dispose();            tabFrame = null;        }        if( Settings.getInstance().getBoolean( "useTabbedWindow" )                 && Settings.getInstance().getBoolean( "dockBuddyList" ) )        {            dockYourself();        }        else if( docked )        {            docked = false;        }        if( !docked )        {            BuddyListContainerFrame f = new BuddyListContainerFrame( this );            frame = f;        }        frame.setVisible( true );        statusMenu.reloadStatusIcons();        statusMenu.setModeChecked( null );        if( Arguments.getInstance().getBoolean( "xmlconsole" ) )        {            ParsedBuddyInfo info = new ParsedBuddyInfo( resources.getString( "xmlConsole" ) );            String userId = info.getUserId().toLowerCase();            final BuddyStatus buddyStatus = BuddyList.getInstance()                    .getBuddyStatus( userId );            buddyStatus.setName( resources.getString( "xmlConsole" ) );            if( buddyStatus.getConversation() == null )            {                buddyStatus.setConversation( new ConsolePanel( buddyStatus ) );                MessageDelegator.getInstance().showPanel(                        buddyStatus.getConversation() );                MessageDelegator.getInstance().frontFrame(                        buddyStatus.getConversation() );            }        }        sound.setSelected(!Settings.getInstance().getBoolean("noSound"));        showOffline.setSelected( Settings.getInstance().getBoolean(            "showOfflineBuddies") );        showAway.setSelected(!Settings.getInstance().getBoolean("dontShowAwayBuddies"));    }    /**     *  Saves the current settings - like the height and width of the buddy list     */    public void saveSettings()    {        if( frame.isVisible() )        {            if( !docked )            {                //save the current buddy list size and position                Dimension size = new Dimension( frame.getSize() );                Point location = new Point( frame.getLocationOnScreen() );                Settings.getInstance().setProperty( "buddyListX",                        new Double( location.getX() ).toString() );                Settings.getInstance().setProperty( "buddyListY",                        new Double( location.getY() ).toString() );                Settings.getInstance().setProperty( "buddyListWidth",                        new Integer( size.width ).toString() );                Settings.getInstance().setProperty( "buddyListHeight",                        new Integer( size.height ).toString() );            }        }        Settings.writeSettings();    }    /**     *  Returns the buddy list tree     *     *@return    the buddy list tree     */    public BuddyListTree getBuddyListTree()    {        return this.buddyListTree;    }    /**     *  Init components just does some initial setup, sets the size and     *  preferred location of the buddy list. Sets up an new initial tree.     */    private void initComponents()    {        JPanel container = this;        container.setLayout( new BorderLayout() );        container.setBorder( BorderFactory.createEmptyBorder( 1, 1, 1, 1 ) );        showOffline.setPreferredSize( new Dimension( 24, 24 ) );        ShowOfflineAction.addItem( showOffline );        showOffline.setToolTipText(resources.getString("showOfflineBuddies"));        showAway.setPreferredSize(new Dimension(24,24));        showAway.setToolTipText(resources.getString("showAwayBuddies"));        ShowAwayAction.addItem(showAway);        sound.setPreferredSize(new Dimension(24,24));        sound.setToolTipText(resources.getString("soundToggle"));        sound.addActionListener(new ActionListener()        {            public void actionPerformed(ActionEvent e) {                Settings.getInstance().setBoolean("noSound", !sound.isSelected());		com.valhalla.Logger.debug( Settings.getInstance().getBoolean( "noSound" ) + "" );            }        });        JPanel buttonPanel = new JPanel();        buttonPanel.setLayout( new BoxLayout( buttonPanel, BoxLayout.X_AXIS ) );        buttonPanel.setBorder( BorderFactory.createEmptyBorder( 1, 1, 1, 1 ) );        buttonPanel.add( showOffline );        buttonPanel.add( Box.createRigidArea(new Dimension(2,0)));        buttonPanel.add(showAway);        buttonPanel.add( Box.createRigidArea(new Dimension(2,0)));        buttonPanel.add(sound);        buttonPanel.add( Box.createHorizontalGlue());        container.add( buttonPanel, BorderLayout.NORTH );        jbButton.addMouseListener( new ButtonListener() );        jbButton.setToolTipText(resources.getString("jbotherMenu"));        jbButton.setIcon( Standard.getIcon( "images/frameicon.png" ) );        statusButton.addMouseListener( new Button2Listener() );        statusButton.setText( resources.getString( "offline" ) );        buddyListTree = new BuddyListTree();        // so the menus get the correct size        JFrame temp = new JFrame();        temp.getContentPane().setLayout(new FlowLayout());        temp.getContentPane().add(jbMenu);        temp.getContentPane().add(statusMenu);        temp.pack();        temp.dispose();        container.add( buddyListTree, BorderLayout.CENTER );        JPanel status = new JPanel();        GridBagLayout gbl = new GridBagLayout();        status.setLayout( gbl );        status.setMaximumSize( new Dimension( 1000, jbButton.getHeight() ) );        GridBagConstraints gbc = new GridBagConstraints();        gbc.fill = GridBagConstraints.HORIZONTAL;        gbc.weightx = 1;        gbc.weighty = 1;        gbc.anchor = GridBagConstraints.EAST;        gbc.insets = new Insets( 1, 1, 1, 1 );        gbc.gridx = 1;        gbc.gridy = 1;        gbl.addLayoutComponent( statusButton, gbc );        gbc.fill = GridBagConstraints.NONE;        gbc.weightx = 0;        gbc.weighty = 0;        gbc.anchor = GridBagConstraints.WEST;        gbc.insets = new Insets( 1, 1, 1, 1 );        gbc.gridx = 0;        gbc.gridy = 1;        gbl.addLayoutComponent( jbButton, gbc );        status.add( jbButton );        status.add( statusButton );        container.add( status, BorderLayout.SOUTH );    }    /**     *  Description of the Class     *     *@author     synic     *@created    April 12, 2005     */    class ButtonListener extends MouseAdapter    {        public void mousePressed( MouseEvent e )        {            jbMenu.showMenu( e.getComponent(), jbButton.getX() - 1, jbButton.getY() - jbMenu.getHeight() - 1 );        }    }    /**     *  Description of the Class     *     *@author     synic     *@created    April 12, 2005     */    class Button2Listener extends MouseAdapter    {        public void mousePressed( MouseEvent e )        {            statusMenu.showMenu( e.getComponent(), jbButton.getX() - 1, statusButton.getY() - statusMenu.getHeight() - 1 );        }    }

⌨️ 快捷键说明

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