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

📄 bswebbrowserplugin.java

📁 一款即时通讯软件
💻 JAVA
字号:
package edu.ou.kmi.buddyspace.plugins.webbrowser;

/*
 * BSWebBrowserPlugin.java
 *
 * Project: BuddySpace
 * (C) Copyright Knowledge Media Institute 2002
 *
 *
 * Created on 27 September 2002, 17:45
 */

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

import org.jabber.jabberbeans.util.*;

import edu.ou.kmi.buddyspace.core.*;
import edu.ou.kmi.buddyspace.gui.*;

import edu.ou.kmi.buddyspace.plugins.*;
//import edu.ou.kmi.buddyspace.plugins.webbrowser.core.*;
import edu.ou.kmi.buddyspace.plugins.webbrowser.gui.*;

/**
 * <code>BSWebBrowserPlugin</code> is main class of web browser plugin to BuddySpace.
 * It provides methods for plugin loading and user interaction.
 *
 * @author  Jiri Komzak, Knowledge Media Institute, Open University, United Kingdom
 */
public class BSWebBrowserPlugin extends BSPlugin
                                implements ActionListener {
    
    //private BSConfBean confBean;
    //private BSConfWinManager confWinMan;
    private JCheckBoxMenuItem showMenuItem;
    private boolean shown = false;
    private BSWebPanel webPanel;
    
    /** Constructor */
    public BSWebBrowserPlugin(BSMainFrame mainFrame, JTabbedPane tabbedPane, BSCore core) {
        super(mainFrame, tabbedPane, core);
    }
    
    /** Inits plugin core */
    protected void initCore() {
        //confBean = new BSConfBean();
    }
    
    /** Inits plugin GUI */
    protected void initGUI() {
        //confWinMan = new BSConfWinManager(mainFrame, tabbedPane);
        Thread t = new Thread() {
            public void run() {
                URL url;
                try {
                    url = new URL("http://jabber.open.ac.uk");
                    //url = new URL("http://www.google.com");
                    //url = new URL("http://kmi.open.ac.uk/projects/buddyspace");
                } catch (MalformedURLException e) {
                    webPanel = null;
                    return;
                }
                webPanel = new BSWebPanel(url);
                if (shown)
                    tabbedPane.addTab("HTML view", webPanel);
            }
        };
        t.start();
    }
    
    /** Adds plugin GUI controls */
    protected void addGUIControls() {
        showMenuItem = new JCheckBoxMenuItem("HTML view tab");
        if (shown)
            showMenuItem.setSelected(true);
        else
            showMenuItem.setSelected(false);
        showMenuItem.addActionListener(this);
        //showMenuItem.setEnabled(false);
        mainFrame.addPluginShowMenuItem(showMenuItem);
    }
    
    /** Connects plugin to BuddySpace beans */
    protected void connectBeans() {
    }
    
    /** Handles connection change to connected */
    public void connected() {
        super.connected();
    }
    
    /** Handles connection change to disconnected */
    public void disconnected() {
    }
    
    /** Handles GUI controls actions */
    public void actionPerformed(ActionEvent evt) {
        if (evt.getSource() == showMenuItem) {
            if (shown) {
                tabbedPane.remove(webPanel);
                shown = false;
                showMenuItem.setSelected(false);
            }
            else {
                tabbedPane.addTab("HTML view", webPanel);
                tabbedPane.setSelectedComponent(webPanel);
                shown = true;
                showMenuItem.setSelected(true);
            }
        }
    }
    
    /** Loads preferences. Empty implementation. */
    protected void loadPreferences() { }
    
    /** Returns components and their names for display in preferences dialog.
     *  Empty implementation - returns null. 
     */
    public void getPreferencesTab(Vector components, Vector names) {}
    
    /** Stores preferences from preferences tab.
     *  Empty implementation. 
     */
    public boolean storePreferences() {
        return true;
    }
    
    
    /** 
     * Performs action within given namespace for given JID.
     * Returns if action was performed.
     */
    public boolean performAction(JID jid, String namespace) {
        if (namespace != null && namespace.equals("http")) {
            if (jid == null) return false;
            String url = jid.toString();
            webPanel.goToURL(url);
            /*if (!shown) {
                tabbedPane.addTab("HTML view", webPanel);
                showMenuItem.setSelected(true);
            }
            tabbedPane.setSelectedComponent(webPanel);*/
            return true;
        }
        else
            return false;
    }
    
    /** Adds supported namespaces and their names */
    public void getSupportedNamespaces(Vector namespaces, Vector names) {
        namespaces.addElement(new String("http"));
        names.addElement(new String("Web page"));
    }
    
    
    /** Updates LAF of all plug-ins  */
    public void updateLAF() {
        SwingUtilities.updateComponentTreeUI(webPanel);
    }
    
}

⌨️ 快捷键说明

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