📄 xpluginbar.java
字号:
/****************************************************************
* XBrowser - eXtended web Browser *
* *
* Copyright (c) 2000-2001 Armond Avanes *
* Refer to ReadMe & License files for more information *
* *
* *
* By: Armond Avanes *
* Armond555@yahoo.com & Armond333@yahoo.com *
* http://xbrowser.sourceforge.net/ *
*****************************************************************/
package xbrowser.widgets;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import java.util.*;
import javax.swing.*;
import xbrowser.*;
import xbrowser.util.*;
import xbrowser.plugin.*;
import xbrowser.plugin.event.*;
public class XPluginBar extends JPanel implements XPluginListener, PropertyChangeListener
{
public XPluginBar()
{
super( new BorderLayout() );
JPanel pnl_north = new JPanel(new BorderLayout());
JLabel lbl_title = XRepository.getComponentBuilder().buildLabel(this, "Title");
Font fnt = lbl_title.getFont();
lbl_title.setFont( fnt.deriveFont(Font.BOLD,fnt.getSize()+2) );
pnl_north.add(lbl_title, BorderLayout.WEST);
pnl_north.add(XRepository.getComponentBuilder().buildFlatButton(new CloseBarAction(), -1, -1), BorderLayout.EAST);
pnl_north.setBorder( BorderFactory.createRaisedBevelBorder() );
add(pnl_north, BorderLayout.NORTH);
add(tabbedPane, BorderLayout.CENTER);
XRepository.getPluginManager().addPluginListener(this);
}
public boolean hasPlugin()
{
return( !plugin_Panel.isEmpty() );
}
public void updateUI()
{
super.updateUI();
if( tabbedPane!=null )
tabbedPane.updateUI();
}
public void pluginAdded(XPluginObject plugin)
{
plugin.addPropertyChangeListener(this);
}
public void pluginRemoved(XPluginObject plugin)
{
plugin.removePropertyChangeListener(this);
}
public void propertyChange(PropertyChangeEvent evt)
{
XPluginObject plugin = (XPluginObject)evt.getSource();
String prop_name = evt.getPropertyName();
if( prop_name.equals("Status") && plugin.getDock()==XProjectConstants.PLUGIN_DOCK_DOCKABLE )
{
if( plugin.getStatus()==XProjectConstants.PLUGIN_STARTED )
addPlugin(plugin);
else if( plugin.getStatus()==XProjectConstants.PLUGIN_STOPPED )
removePlugin(plugin);
}
else if( prop_name.equals("Dock") )
{
if( plugin.getDock()==XProjectConstants.PLUGIN_DOCK_DOCKABLE )
{
if( plugin.getStatus()==XProjectConstants.PLUGIN_STARTED )
addPlugin(plugin);
}
else
removePlugin(plugin);
}
}
private void addPlugin(XPluginObject plugin)
{
JPanel pnl_plugin = createPluginPanel(plugin);
plugin_Panel.put(plugin, pnl_plugin);
tabbedPane.addTab(plugin.getTitle(), plugin.getIcon(), pnl_plugin);
}
private void removePlugin(XPluginObject plugin)
{
JPanel pnl_plugin = (JPanel)plugin_Panel.remove(plugin);
tabbedPane.remove(pnl_plugin);
}
private JPanel createPluginPanel(XPluginObject plugin)
{
JPanel pnl = new JPanel( new BorderLayout(0,0) );
JPanel pnl_north = new JPanel( new BorderLayout(0,0) );
JPanel pnl_east = new JPanel( new FlowLayout() );
pnl_east.add( XRepository.getComponentBuilder().buildFlatButton(new FloatablePluginAction(plugin), -1, -1) );
pnl_east.add( XRepository.getComponentBuilder().buildFlatButton(new ClosePluginAction(plugin), -1, -1) );
pnl_north.add(new JLabel(plugin.getTitle()), BorderLayout.WEST);
pnl_north.add(pnl_east, BorderLayout.EAST);
pnl.add(pnl_north,BorderLayout.NORTH);
pnl.add(plugin.getComponent(),BorderLayout.CENTER);
//pnl.setBorder(BorderFactory.createTitledBorder(""));
return pnl;
}
private class CloseBarAction extends XDefaultAction
{
public CloseBarAction()
{
super(XPluginBar.this, "CloseBar", null);
}
public void actionPerformed(ActionEvent e)
{
XRepository.getConfiguration().setSideBar(false);
}
}
private class ClosePluginAction extends XDefaultAction
{
public ClosePluginAction(XPluginObject plugin)
{
super(XPluginBar.this, "ClosePlugin", null);
this.plugin = plugin;
}
public void actionPerformed(ActionEvent e)
{
plugin.stop();
}
// Attributes:
private XPluginObject plugin = null;
}
private class FloatablePluginAction extends XDefaultAction
{
public FloatablePluginAction(XPluginObject plugin)
{
super(XPluginBar.this, "Floatable", null);
this.plugin = plugin;
}
public void actionPerformed(ActionEvent e)
{
plugin.setDock(XProjectConstants.PLUGIN_DOCK_FLOATABLE);
}
// Attributes:
private XPluginObject plugin = null;
}
// Attributes:
private static XPluginUIManager instance = null;
private JTabbedPane tabbedPane = new JTabbedPane();
private Map plugin_Panel = new HashMap();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -