Search in sources :

Example 1 with LinkListener

use of org.xhtmlrenderer.swing.LinkListener in project gate-core by GateNLP.

the class ControllerMetadataViewer method init.

@SuppressWarnings("rawtypes")
@Override
public Resource init() throws ResourceInstantiationException {
    setLayout(new BorderLayout());
    add(new JScrollPane(display), BorderLayout.CENTER);
    try {
        builder = builderFactory.newDocumentBuilder();
    } catch (ParserConfigurationException e) {
        throw new ResourceInstantiationException("Unable to construct an XML parser", e);
    }
    if (Configuration.isTrue("xr.use.listeners", true)) {
        List l = display.getMouseTrackingListeners();
        for (Iterator i = l.iterator(); i.hasNext(); ) {
            FSMouseListener listener = (FSMouseListener) i.next();
            if (listener instanceof LinkListener) {
                display.removeMouseTrackingListener(listener);
            }
        }
        display.addMouseTrackingListener(new LinkListener() {

            @Override
            public void linkClicked(BasicPanel panel, String uri) {
                // open any links in an actual web browser
                MainFrame.getInstance().showHelpFrame(uri, null);
            }
        });
    }
    return this;
}
Also used : JScrollPane(javax.swing.JScrollPane) BasicPanel(org.xhtmlrenderer.swing.BasicPanel) BorderLayout(java.awt.BorderLayout) LinkListener(org.xhtmlrenderer.swing.LinkListener) Iterator(java.util.Iterator) List(java.util.List) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) FSMouseListener(org.xhtmlrenderer.swing.FSMouseListener) ResourceInstantiationException(gate.creole.ResourceInstantiationException)

Aggregations

ResourceInstantiationException (gate.creole.ResourceInstantiationException)1 BorderLayout (java.awt.BorderLayout)1 Iterator (java.util.Iterator)1 List (java.util.List)1 JScrollPane (javax.swing.JScrollPane)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 BasicPanel (org.xhtmlrenderer.swing.BasicPanel)1 FSMouseListener (org.xhtmlrenderer.swing.FSMouseListener)1 LinkListener (org.xhtmlrenderer.swing.LinkListener)1