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

📄 conversationpanel.java

📁 JBother是纯Java开发的Jabber(即时消息开源软件)客户端。支持群组聊天
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    /**     * Returns the buddy status for this dialog     *     * @return the buddy passed in to the constructor     */    public BuddyStatus getBuddy() {        return buddy;    }    /**     * Listens for a close event, and either makes the dialog hidden or removes     * it from the dialog tracker     *     * @author Adam Olsen     * @created October 26, 2004     * @version 1.0     */    class CloseListener implements ActionListener {        /**         * @param e         *            the event         */        public void actionPerformed(ActionEvent e) {            timer.stop();            closeHandler();            timer = null;        }    }    /**     * Checks to see if we are preserving messages. If so, it starts the timer,     * otherwise it just closes the panel     */    public void checkCloseHandler() {        if (Settings.getInstance().getProperty("preserveMessages") == null) {            closeHandler();        } else {            startTimer();            if (!Settings.getInstance().getBoolean("useTabbedWindow")) {                frame.setVisible(false);            } else {                BuddyList.getInstance().removeTabPanel(this);            }        }    }    /**     * Destroys the dialog, disposes the containing frame if there is one and     * removes the panel from the TabFrame if required.     */    public void closeHandler() {        if(this instanceof ChatPanel) ((ChatPanel)this).removeScroll();        textEntryArea.getInputMap().clear();        textEntryArea = null;        closeLog();        if (frame != null) {            frame.setVisible(false);            frame.dispose();        }        if (buddy != null) {            com.valhalla.Logger.debug("Closing ConversationPanel for "                    + buddy.getUser());            buddy.setConversation(null);        }        if (Settings.getInstance().getBoolean("useTabbedWindow")) {            BuddyList.getInstance().removeTabPanel(this);        }        timer.stop();        com.valhalla.Logger.debug("timer is now null");        timer = null;        MessageDelegator.getInstance().removePanel(this);    }    /**     * Opens a <code>com.valhalla.jbother.LogViewerDialog</code>     */    public void openLogWindow() {        new LogViewerDialog(this, buddy.getUser());    }    /**     * Opens a log and starts it.     */    public void startLog() {        if (buddy == null)            return;        // for loggingg        if (Settings.getInstance().getBoolean("keepLogs")) {            String logFileName = LogViewerDialog.getDateName() + ".log";            String logFileDir = JBother.profileDir                    + File.separatorChar                    + "logs"                    + File.separatorChar                    + this.buddy.getUser().replaceAll("@", "_at_").replaceAll(                            "\\/", "-");            File logDir = new File(logFileDir);            if (!logDir.isDirectory() && !logDir.mkdirs()) {                Standard.warningMessage(this, resources.getString("log"),                        resources.getString("couldNotCreateLogDir"));            }            String logEnc =                Settings.getInstance().getProperty("keepLogsEncoding");            conversationArea.setLogFile(new File(logDir, logFileName), logEnc);        }    }    /**     * Sets a message to offline (displays "this message is offline")     */    public void setOfflineMessage() {    }    /**     * @return a String representing the current time the format:     *         [Hour:Minute:Second]     * @param d     *            the date stamp to use     */    public static String getDate(Date d) {        if (d != null) {            // calculation of the offset is no longer needed            // perhaps a smack change?            //d = new Date(d.getTime()              //      + TimeZone.getDefault().getOffset(d.getTime()));        } else {            d = new Date();        }        Calendar mtime = Calendar.getInstance();        mtime.setTime(d);        Calendar today = Calendar.getInstance();        today.setTime(new Date());        SimpleDateFormat formatter = new SimpleDateFormat("[HH:mm:ss]");        if (mtime.get(Calendar.MONTH) != today.get(Calendar.MONTH)                || mtime.get(Calendar.DAY_OF_MONTH) != today                        .get(Calendar.DAY_OF_MONTH)                || mtime.get(Calendar.YEAR) != today.get(Calendar.YEAR)) {            formatter = new SimpleDateFormat("[MM/dd@HH:mm]");        }        String date = formatter.format(d);        return date;    }    /**     * Receives a message     *     * @param sbj     *            the subject of the message     * @param body     *            the message body     * @param resource     *            the message resource     * @param date     *            the timestamp when the message was received     */    public void receiveMessage(String sbj, String delayInfo, String body, String resource,            Date date, boolean decryptedFlag, boolean verifiedFlag) {        receiveMessage();    }    /**     * Calls the received message events     */    public void receiveMessage() {        MessageDelegator.getInstance().showPanel(this);        stopTimer();        JFrame f = frame;        boolean isFocused = true;        if (Settings.getInstance().getBoolean("useTabbedWindow")) {            f = BuddyList.getInstance().getTabFrame();            BuddyList.getInstance().getTabFrame().markTab(this);            isFocused = f.isFocused();        } else {            if (!frame.isVisible()) {                frame.setVisible(true);            } else if (Settings.getInstance().getBoolean("focusWindow")) {                isFocused = frame.isFocused();                frame.toFront();            } else                isFocused = frame.isFocused();        }        if (Settings.getInstance().getBoolean("usePopup")            // && !isFocused                && f != null) {            if (buddy != null && buddy.getName() != null) {                NotificationPopup.showSingleton(f, resources                        .getString("messageReceived"), "<b>"                        + resources.getString("from") + ":</b>&nbsp;&nbsp;"                        + buddy.getName(),this);            } else {                NotificationPopup.showSingleton(f, resources                        .getString("messageReceived"), "Message Received",this);            }        }        com.valhalla.jbother.sound.SoundPlayer.play("receivedSound");    }    public void setLastReceivedMessage(Message message) {        this.lastReceived = message;        MessageReceivedEvent event = new MessageReceivedEvent(this);        Message newMessage = new Message( message.getTo(), message.getType() );        newMessage.setSubject(message.getSubject());        newMessage.setBody(message.getBody());        newMessage.setThread(message.getThread());        event.setMessage(newMessage);        com.valhalla.pluginmanager.PluginChain.fireEvent(event);    }    /**     * Abstract createFrame - creates the containing frame of this panel     */    public abstract void createFrame();    /**     * Stops the close timer     */    public void stopTimer() {        timer.stop();    }    /**     * Starts the closet imer     */    public void startTimer() {        timer.start();    }    /**     * Displays a "disconnected" message"     */    public void disconnected() {        conversationArea.append(getDate(null) + " **** " + resources.getString("disconnected"), ConversationArea.BLACK, true);    }    public void updateStyle(Font font){}    /**     * Closes the log file     */    public void closeLog() {        conversationArea.closeLog();    }    public void finailize()    {        String user = "";        if(buddy != null) user = buddy.getUser();        com.valhalla.Logger.debug("Finalize called for conversationpanel " + user);    }}

⌨️ 快捷键说明

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