Changeset 537


Ignore:
Timestamp:
11/26/13 16:06:38 (10 years ago)
Author:
ngw8
Message:

JfxBrowser: URI is remembered between closing and reopening Expeditee (by saving to the widget args)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/items/widgets/JfxBrowser.java

    r536 r537  
    1414import java.net.URL;
    1515import java.net.URLClassLoader;
    16 import java.util.List;
    1716
    1817import javax.swing.JPanel;
     
    4746        static Class WebEngine;
    4847        static Method WebEngineLoad;
     48        static Method WebEngineGetLocation;
    4949
    5050        static {
    5151                String javaLibDir = System.getProperty("java.home") + File.separator + "lib" + File.separator;
    5252                try {
    53                         System.out.println(javaLibDir);
    5453                        ClassLoader classLoader = ClassLoader.getSystemClassLoader();
    5554
     
    6160                        addURL.invoke(classLoader, jar.toURI().toURL());
    6261
    63                         System.out.println(System.getProperty("java.class.path"));
    64 
    6562                        JFXPanel = Class.forName("javafx.embed.swing.JFXPanel", false, classLoader);
    66 
    67                         final File f = new File(JFXPanel.getProtectionDomain().getCodeSource().getLocation().getPath());
    68                         System.out.println(f.getPath());
    6963
    7064                        Platform = classLoader.loadClass("javafx.application.Platform");
     
    8882                        WebEngine = classLoader.loadClass("javafx.scene.web.WebEngine");
    8983                        WebEngineLoad = WebEngine.getMethod("load", String.class);
     84                        WebEngineGetLocation = WebEngine.getMethod("getLocation");
    9085
    9186
     
    212207
    213208        public JfxBrowser(Text source, String[] args) {
    214                 // Testing proxy auth
    215                 super(source, new WebBrowserPanel("http://stackoverflow.com"), -1, 500, -1, -1, 300, -1);
     209                // Initial page is either the page stored in the arguments (if there is one stored) or Google
     210                super(source, new WebBrowserPanel((args != null && args.length > 0) ? args[0] : "http://google.com"), -1, 500, -1, -1, 300, -1);
    216211
    217212                _browser = (WebBrowserPanel) _swingComponent;
     
    221216                try {
    222217                        WebEngineLoad.invoke(WebViewGetEngine.invoke(this._browser.webview), url);
    223                        
    224218                } catch (IllegalAccessException e) {
    225219                        e.printStackTrace();
     
    233227        @Override
    234228        protected String[] getArgs() {
    235                 return null;
    236         }
    237 
    238         @Override
    239         public void setSourceData(List<String> data) {
    240                 super.setSourceData(data);
    241                 if (data != null && data.size() > 0) {
    242                         navigate(data.get(0));
    243                 }
    244         }
    245        
    246         @Override
    247         protected List<String> getData() {
    248                 return _textRepresentation.getData();
     229                String[] r = null;
     230                if (this._browser.webview != null) {
     231                        try {
     232                                r = new String[] { (String) WebEngineGetLocation.invoke(WebViewGetEngine.invoke(this._browser.webview)) };
     233                        } catch (IllegalAccessException e) {
     234                                e.printStackTrace();
     235                        } catch (IllegalArgumentException e) {
     236                                e.printStackTrace();
     237                        } catch (InvocationTargetException e) {
     238                                e.printStackTrace();
     239                        } catch (SecurityException e) {
     240                                e.printStackTrace();
     241                        }
     242                }
     243                return r;
    249244        }
    250245}
Note: See TracChangeset for help on using the changeset viewer.