📄 xdocumentselector.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.plugin.defaults.documentselector;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import xbrowser.plugin.*;
import xbrowser.doc.*;
import xbrowser.doc.event.*;
import xbrowser.container.event.*;
import xbrowser.options.*;
public class XDocumentSelector extends JList implements XGUIPlugin, ListSelectionListener, XDocumentContainerListener, XDocumentListener
{
///////////////// XGUIPlugin Interface /////////////////////
public void init()
{
setModel( new DefaultListModel() );
setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
setSelectionModel( new DefaultListSelectionModel() );
ToolTipManager.sharedInstance().registerComponent(this);
registerListeners();
}
public void start()
{
}
public void stop()
{
}
public void destroy()
{
}
public void setContext(XPluginContext context)
{
this.context = context;
context.getResourceManager().initResourceBundle("XDocumentSelector");
}
public Component getComponent()
{
return( new JScrollPane(this) );
}
public String getTitle()
{
return context.getResourceManager().getProperty(this, "Title");
}
public XOptionPage getOptionPage()
{
return null;
}
///////////////// XGUIPlugin Interface /////////////////////
private void registerListeners()
{
addMouseListener( new MouseAdapter() {
public void mouseReleased(MouseEvent e)
{
if( e.isPopupTrigger() )
{
int index = locationToIndex(e.getPoint());
if( index!=-1 )
{
setSelectedIndex(index);
context.getBrowser().showPopupMenu(XDocumentSelector.this, null, e.getX(), e.getY());
}
}
}
});
addListSelectionListener(this);
context.getBrowser().addDocumentContainerListener(this);
}
public void valueChanged(ListSelectionEvent e)
{
XDocument doc = (XDocument)getSelectedValue();
if( doc!=null )
context.getBrowser().getDocumentContainer().activateDocument(doc);
}
public String getToolTipText(MouseEvent e)
{
if( e==null )
return null;
int index = locationToIndex(e.getPoint());
if( index!=-1 )
{
XDocument doc = (XDocument)getModel().getElementAt(index);
String path = doc.getPageCompletePath();
return( path.equals("") ? null : path );
}
else
return null;
}
///////////////// XDocumentContainerListener Interface /////////////////////
public void documentActivated(XDocument doc)
{
setSelectedValue(doc, true);
}
public void documentAdded(XDocument doc)
{
doc.addDocumentListener(this);
((DefaultListModel)getModel()).addElement(doc);
setSelectedValue(doc,true);
}
public void documentClosed(XDocument doc)
{
doc.removeDocumentListener(this);
((DefaultListModel)getModel()).removeElement(doc);
}
///////////////// XDocumentContainerListener Interface /////////////////////
///////////////// XDocumentListener Interface /////////////////////
public void documentLoadingStarted(XDocument doc)
{
repaint();
}
public void documentLoadingFinished(XDocument doc)
{
repaint();
}
public void pageAddedToDocumentHistory(XDocument doc, String url)
{
}
///////////////// XDocumentListener Interface /////////////////////
// Attributes:
private XPluginContext context;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -