view netx/net/sourceforge/jnlp/runtime/html/browser/LinkingBrowser.java @ 1493:7f00f3fc1cf6

reworked showDocument logic * netx/net/sourceforge/jnlp/config/BasicValueValidators.java: added special validator for browser * netx/net/sourceforge/jnlp/config/Defaults.java: used this validator * netx/net/sourceforge/jnlp/config/DeploymentConfiguration.java: declared browser's constants and environment variable * netx/net/sourceforge/jnlp/resources/Messages.properties: removed invalid lines, added new lines * netx/net/sourceforge/jnlp/resources/Messages_cs.properties: removed invalid lines, * netx/net/sourceforge/jnlp/resources/Messages_de.properties: removed invalid lines, * netx/net/sourceforge/jnlp/resources/Messages_pl.properties: removed invalid lines, * netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java: showDocument now works * netx/net/sourceforge/jnlp/runtime/Translator.java: added shortcut method to call call VVPossibleBrowserValues * netx/net/sourceforge/jnlp/runtime/html/browser/LinkingBrowser.java: split creation from stand alone launch * netx/net/sourceforge/jnlp/services/XBasicService.java: fully reworked showDocument. Focus on standard desktop api and customization * tests/reproducers/signed/ShowDocument/resources/ShowDocumentApplet.jnlp: test jnlp for applet's context.showDocument * tests/reproducers/signed/ShowDocument/resources/ShowDocumentMain.jnlp: test jnlp for application's basicService.showDocument * tests/reproducers/signed/ShowDocument/resources/document.txt: document to be shown in test * tests/reproducers/signed/ShowDocument/srcs/ShowDocument.java: body of applet/jnlp-app * tests/reproducers/signed/ShowDocument/testcases/ShowDocumentTest.java: two testcases - one for applet, second for app. Both running on headless.
author Jiri Vanek <jvanek@redhat.com>
date Fri, 12 Oct 2018 13:30:42 +0200
parents 074a19daa4d3
children
line wrap: on
line source

/* 
   Copyright (C) 2012 Red Hat, Inc.

This file is part of IcedTea.

IcedTea is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 2.

IcedTea is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with IcedTea; see the file COPYING.  If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version.
 */
package net.sourceforge.jnlp.runtime.html.browser;

import java.net.Authenticator;
import java.net.ProxySelector;
import java.net.URL;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import net.sourceforge.jnlp.browser.BrowserAwareProxySelector;
import static net.sourceforge.jnlp.runtime.JNLPRuntime.getConfiguration;
import net.sourceforge.jnlp.security.JNLPAuthenticator;
import net.sourceforge.jnlp.util.logging.JavaConsole;

public class LinkingBrowser extends JTabbedPane {

    private final HtmlBrowserPanel browser;
    private final LinksPanel linksPanel = new LinksPanel();

    public LinkingBrowser(final URL url) {
        this(url, false);
    }

    public LinkingBrowser(final String url) {
        this(url, false);
    }

    public LinkingBrowser(final URL url, boolean socket) {
        super();
        browser = new HtmlBrowserPanel(url, socket);
        createGui(browser);
    }

    public LinkingBrowser(final String url, boolean socket) {
        super();
        browser = new HtmlBrowserPanel(url, socket);
        createGui(browser);
    }

    private void createGui(HtmlBrowserPanel lBrowser) {
        linksPanel.addressChangeded(lBrowser.getUrl());
        linksPanel.parseAndAdd(lBrowser.getCurrentSource());
        linksPanel.setInternalBrowser(lBrowser);
        lBrowser.addDocumentChangedListener(linksPanel);
        this.addTab("html", lBrowser); //jeditropane
        this.addTab("links", new JScrollPane(linksPanel)); // set of found links - copyToClipboard, execute in browser, show...

    }

    public static void showStandAloneWindow(String url, boolean socket) {
        if (JavaConsole.canShowOnStartup(true)) {
            JavaConsole.getConsole().showConsoleLater();
        }
        // plug in a custom authenticator and proxy selector
        Authenticator.setDefault(new JNLPAuthenticator());
        BrowserAwareProxySelector proxySelector = new BrowserAwareProxySelector(getConfiguration());
        proxySelector.initialize();
        ProxySelector.setDefault(proxySelector);
        createFrame(url, socket, JFrame.EXIT_ON_CLOSE);
    }

    public static void createFrame(String url, boolean socket, int action) {
        HtmlBrowserPanel.warn();
        JFrame f = new JFrame();
        f.add(new LinkingBrowser(url, socket));
        f.pack();
        f.setDefaultCloseOperation(action);
        f.setVisible(true);
    }

    public HtmlBrowserPanel getBrowser() {
        return browser;
    }

    public LinksPanel getLinksPanel() {
        return linksPanel;
    }

}